C# is a multiparadigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.

learn more… | top users | synonyms

4
votes
3answers
143 views

Darkness Emitting Light Source Unity

I was wondering if it was possible to create a light source in Unity, one that "sucks" light from the environment. Negative value does not seem to work in Unity, as pointed out by many. It is quite ...
0
votes
0answers
16 views

How can I make an expandable menu and assign names to buttons randomly from an external file using Unity?

I'd like to create a menu on the lower left side of the screen which will present some options (guns) to the player. The number of options should change based on how well a player is doing. In other ...
1
vote
1answer
28 views

What is the maximum value of a LayerMask in Unity?

What is the maximum value of a LayerMask in Unity (the value when all layers are included)? And how can I find it using C# bitwise operations? I tried ~0 but it shows -1 in intellisense. Thanks in ...
1
vote
0answers
33 views

How can I change the list of enum options displayed in the inspector?

I have an array of enums: using UnityEngine; public class EnumsInInspector : MonoBehaviour { [SerializeField] public EnumType[] myEnums = new EnumType[3]; public enum EnumType { ...
0
votes
1answer
149 views

Continuous Jumping Cycle

The script makes a GameObject jump using realistic gravity and reach a specific target. The GameObject jumps relative to the target, thus adjusting its trajectory. It also works while the target point ...
0
votes
2answers
4k views

Play animation when click on each player with in maincamera unity3d

I have 3 gameobjects (player1, player2, player3). I attached a script "playerscript" to these game objects. In the main camera, I have added another script called "testscript". Clicking on a player ...
0
votes
1answer
357 views

Unity5 TextAsset not functioning in WebPlayer

Preface I am working on a 2D Platformer in Unity5 utilizing TileMap techniques. I have a working system to read "Room Tile Data" from JSON files with the Unity TextAsset Class and the Newtonsoft ...
0
votes
3answers
104 views

A method to create and assign a name to a GameObject (Unity)

I'm trying to create a function that takes in a name of an object in the editor and assigns this accordingly as well as the name of a sprite, rigidbody, etc. Basically what I have so far is- ...
10
votes
2answers
5k views

Microsoft XNA Platformer Example, is the Collsion Detection implemented accurately?

The example provided by Microsoft seems as if the collision detection (from what I can see) will have a small error. When the user collides with an Unpassable tile, the depth of the intersection is ...
0
votes
1answer
103 views

How to load sprite from JSON?

i know how to load text, but idk how to load texture from json.. this my c#: public void soalbegin(){ filepath = System.IO.Path.Combine(Application.streamingAssetsPath, "soal.json"); ...
3
votes
1answer
88 views

Unity3D Pathfinder with Crossings

I'm trying to bring traffic on my street system. The main problem for me are the different lanes and crossings and to make it complete the different types of paths. I've tried a bit with the ...
0
votes
2answers
961 views

Instantiating a prefab as a child to another game object (spawn point) - Unity 3D - C#

I am currently working on a 3d game in unity in C#. I've been following a series of tutorials on youtube (burgzerg arcade) for quite a while now, and i've came across the following error. This error ...
0
votes
3answers
122 views

Move Camera When Player Move C#

i developing side Scrolling endless Game. i want to Change X Axis of camera as player moving to Right. and i almost Done That. but the problem is when move Camera to the Right then its look so stiff ...
1
vote
1answer
98 views

How to remove destroyed clones out of the Hierarchy in Unity2D

I made a 2D edge collider which on contact destroys the other gameobject. When I launch the game all the other gameobjects in fact get destroyed but the clones are still listed in the Hierarchy. How ...
0
votes
0answers
37 views

Unity2D wall jumping not working correctly?

i've been working on this project for the past week using unity engine, its a 2d platformer similiar to super meat boy.I've been able to program jump sustain(jump higher when you press space longer), ...
0
votes
1answer
105 views

Mode 7 in xna/monogame

I want achieve a view like Mode 7 from snes games where the closer textures get stretched out more and more far away textures look smaller. Something like this: What I have in my project at the ...
4
votes
1answer
101 views

Monogame Startup Memory Spike

I am currently porting a game from WP7 using XNA to WP8.1 using MonoGame. I have been putting considerable effort into optimizing my game to be under the 185MB memory limit for low-memory phones. I ...
0
votes
1answer
59 views

Zoom at a specific point using Orthographic camera

Currently I can perform Zoom which seems to be working fine but essentially what I'm really trying to do is zoom on a position offset from center as currently when I zoom then zoom is performed at the ...
0
votes
0answers
19 views

Trigonometric movement cause problem when holding player inside bounds

In my game I have a Player class. Here is what it looks like. public void Update(GameTime gameTime) { // Controls kb = Keyboard.GetState(); if (kb.IsKeyDown(Keys.W)) ...
0
votes
0answers
25 views

How to get vectices of a sprite in correct order in Unity?

Currently, when I examine sprite.vertices, I see that it is ordered in crossed way, like: one from bottom, one from up, another one from somewhere else... etc. I need the correct order to make array ...
0
votes
1answer
15 views

Replace text in Unity [closed]

i tried to look up my question but didn't really find an answer that works for my situation. I'm using this unity asset called Dialoguer to create interactive dialogues. What I'm trying to do is to ...
2
votes
1answer
113 views

Drawing Farseer Fixtures

Is there any way how to draw a Polygon / Fixture from Farseer Physics with XNA? As I deform these polygons at runtime I can't take any texture from my Content folder, the texture must be generated at ...
1
vote
2answers
26 views

Translating a world position to an array position

Lets keep this simple, so, assuming I have an array like this ... var array = new bool[10,10,10]; .. and then I have a start and end vector3 ... var start = new Vector3(-21,-21,-21); var end = new ...
0
votes
1answer
59 views

How can I instantiate in the current rotation in Unity 2d?

Backstory I'm currently working on a 2D sidescroller/platform game as a hobby, and I just started recently. Followed a few tutorials and such I managed to wrote my own code for basic command like ...
0
votes
2answers
265 views

How to properly give Image source for multiple sources?

I'm writing a script to change the image on the button based on previous selection. Another script is giving the CurrentAvatar variable once previous button is pressed. My problem is i can't seem to ...
0
votes
0answers
36 views

Save and retrieve image from database in unity

I have done a sample to insert and retrieve data from MySQL in unity.Now I need to insert and retrieve image from MYSQL in unity. The images are files selected by the user from their filesystem. Can ...
0
votes
1answer
67 views

Raycast from ScreenCenter hits object but does not return its tag

Here is my code: using UnityEngine; using System.Collections; public class Crosshair : MonoBehaviour { public Camera cam; RaycastHit hit; Quaternion rot; // Update is called once per ...
0
votes
1answer
98 views

Unity3D - Using AddRelativeForce to push an object forever in zero gravity environment

Ok, I use AddRelativeForce to basically push an object. But it suppose to keep flying and keep accelerating as I hold down the key because I didn't set gravity. I just started Unity3D last month, so ...
0
votes
1answer
65 views

Add singleton to an existing gameobject in Unity via script

I did notice that if I assign scripts that generate singleton classes (for my managers), to an empty game object, everything works fine. Now I would like to start the scene with the empty game ...
0
votes
1answer
47 views

Script for non-stop enabling/disabling “Is trigger” on collliders2d in Unity3D?

I had asked before that I have a problem with too many colliders in one spot and that some upgrades of towers I have are buggy due to that. It has come to my notice, that whenever I enable the "Is ...
0
votes
0answers
41 views

Purple screen when using vertex shaders

Alright, so I've tried everything I can think of. I've put in over 10 hours into this crap, but nothing seems to work (tried multiple online tutorials as well). Always purple screen. Here is the ...
1
vote
1answer
21 views

Unity RaycastHit2D sprites error C#. Figured out that this code only works on 3D colliders so how do I change it so that I can use it on 2D colliders?

Figured out that this code only works on 3D colliders so how do I change it so that I can use it on 2D colliders? Below is the c# code. using UnityEngine; // This script allows you to drag this ...
0
votes
2answers
141 views

Should clients in an online game access the database directly or through a game server?

first im total noob about c# and mysql. Just trying to find which way is better. i believe your answers prevents me from losing plenty of time. Online game(not more than 50 users at pre-alpha. Not ...
1
vote
1answer
160 views

What can I do in Unity3D to optimize the way I'm calculating contrast of a texture2D?

I have this contrast script right now in Unity: public void ApplyContrast(string contrast) { try { double contrastD = Convert.ToDouble(contrast); //Make ...
3
votes
3answers
177 views

Separate “Battle Character” class from “Character” class?

So I have a Class called Character which represents all the player, his companions, and all enemies. This class does a lot of things including performing actions upon other characters, and upon the ...
0
votes
3answers
167 views

Correct architecture for weapon class in RPG

So, I'm a little stuck on what the best way to implement weapons is. The problem I'm running into is, what exactly is a weapon. I have a Player Class that has an attack method. public class ...
1
vote
0answers
89 views

Turning On/Off Vsync no longer working when rendering to an offscreen buffer

I have this reaallly strange issue that as soon as I render to an offscreen framebuffer I am no longer able to toggle VSync while my application is running. I am using OpenTK as the opengl wrapper, ...
2
votes
0answers
108 views

Struggling with simple orthographic projection for a 2D setup

I'm trying to build a simple setup for 2D using SharpDX. Basically I want to supply my vertices in classic Cartesian coordinates: X-right, Y-up, starting with (0,0) in bottom-left corner. I've had ...
0
votes
1answer
44 views

Rotate a UI Image exactly 360 degrees over the course of 1 second?

I have a UI Image that I want the user to click and have it rotate 360 degrees once on the z axis. I can get it to rotate through a coroutine but I'm having trouble making it stop once it is started. ...
1
vote
1answer
179 views

Monogame / XNA - Multple 2D Cameras (Rectangle) on screen

I recently started building a simple 2D roguelike game using Monogame 3.4. I was keen on building the game "engine" myself as I saw it as a fun learning curve. Monogame was pretty much the best option ...
1
vote
1answer
424 views

How can I use a lookup table for brightness and contrast?

Currently, I implemented a rudimentary brightness and contrast algorithm that changes brightness and contrast pixel by pixel. This was super inefficient performance wise and the algorithm looked a bit ...
1
vote
1answer
232 views

How to detect collision position and that position's texture color in Unity?

I have a prefab and I use Circlecollider2D for physics operations. I want to detect the color of the contact position of the collided objects ? Is is possible by using Unity's collider classes ?
1
vote
1answer
36 views

Unity3d Transfer of value from one script to another

Script 1 public class enemy : MonoBehaviour { private Vector3 Player; private Vector2 PlayerDirection; public float Xdif; public float Ydif; private float speed; private ...
0
votes
1answer
21 views

InvalidOperationException when peeking from a stack within custom editor

I've got a simple state machine for handling game states which works using GameObjects that I enable/disable in order to switch the states. Since some states can be loaded additively (such as the ...
1
vote
2answers
207 views

Help on transition from one position to another

I'm pretty sure I'm over thinking stuff, but I can't seem to figure this out. I want to move the object from one location to another. Here's what I got. I searched this up earlier here, and I found ...
0
votes
1answer
59 views

Boolean change when clicking the left mouse button (not working)

I want to change a boolean when I click the left mouse button, but it doesn't work as expected. I use this method: if (m.LeftButton == ButtonState.Released && m_Old.LeftButton == ...
0
votes
3answers
63 views

Gameobject not destroyed OnCollisionEnter

I have this GameObject with the tag coin I am trying to destroy when the player collides with it using this code located in a player script attached to the player public void ...
-1
votes
1answer
41 views

Making the player Jump in like a Upper - Right manner in Unity

Ok so i'm new to unity and I am trying to make this simple ball game . Now in a situation I want the ball to jump in a diagonal manner (i.e W + D ). Scrip that I have makes the ball jump only Up and ...
0
votes
0answers
25 views

LineRenderer doesn't apply material in 2D Unity5

I'm making something that draw lines with mouse on top of everything (in 2D), but the color of the line is always purple even though I assign a material to the line renderer. I could change the color ...
3
votes
1answer
73 views

Why is quad rendered at the center (0,0) instead of top left when using orthographic projection

I have been trying to render a quad(containg a texture) using orthographic camera so that the quad can be rendered using the screen coordinates directly. I started of by rendering just a triangle ...