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

0
votes
1answer
23 views

Swipe Detection with mouse in Unity

This is my swipe detection code. This code uses touch input. I want to do this using the left mouse button. So basically I want to 'swipe' using the mouse.How can I achieve that? public float maxTime;...
7
votes
1answer
129 views

How to await async operations / coroutines?

I'm looking for a generic / reusable way to wait for coroutines and asynchronous operations to finish in Unity 5, similiar to C#5's await keyword. The simplest way I can think of is something like ...
1
vote
2answers
26 views

GetComponentsInChildren<GUIText>().text - does not contain a definition

My Slider GameObject has a GUIText child. I am writing a C# script that should change the text component in the GUIText, but instead of this I am getting: error CS1061: Type UnityEngine.GUIText[]' ...
2
votes
1answer
225 views

2D lighting causes black rings to appear

A year ago I implemented 2d lighting in XNA using sprites. The sprites I used were created by placing a soft white photoshop brush on a transparant background. The result was this: (lights only) ...
0
votes
1answer
115 views

2d Player animation issue in UNITY 3D

I have a player and i want to move the player from left to right. I can move the player by the keyboard events.but the problem is that when i release the key the player animation should be idle. ...
-3
votes
2answers
43 views

How to make an OnCollision reset level script?

I am making a game and I want to make a script that if a player collides with the resetting object the scene will reset/reload.
1
vote
0answers
27 views

How to disable and enable a randomly generated prefab in an endless runner 3d

Hi all I have been experimenting the endless runner game for some time and needed to optimize it. I read some articles about optimizing my game and it says that once you instantiate the prefabs in the ...
3
votes
1answer
276 views

Handling touch input with Event Trigger

I wrote a simple script to control my 'Player' object: using UnityEngine; using System.Collections; public class PlayerMovement : MonoBehaviour { public float jumpVelocity = 10; ...
0
votes
0answers
49 views

How to keep my player in center of path.?

I want to keep my player in center of the path. I have different paths like strait and 90 degree rotated. I want keep my player moving in center in center like temple run also when I rotate my player ...
0
votes
0answers
16 views

Can`t login in twitter with Fabric! [migrated]

I use fabric for Twitter Share function in my Unity game (Android). I follow all instructions, but I can`t authorize in twitter. But i have my app on dashboard in my fabric account! Full code: ...
1
vote
1answer
53 views

MonoGame creates a copy of song files in XNBs location

I'm having a problem. I've been adding .wma files to the Content Pipeline app to be used as my game's background music. But today when I opened the solution/project/content/bin/music folder I spotted ...
0
votes
1answer
376 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 ...
9
votes
2answers
315 views

Entity component system - game progression

I'm quite new to game development (but not to programming) and I'm trying to figure out what would be the best way to handle inter-world communication. What I mean is this: I've been reading about ...
1
vote
0answers
17 views

UNET Performance of (many) Kinematic Rigidbodies

I am building a game in Unity in C# using the UNET networking elements. I am trying to figure out what is the performance cost of kinematic rigidbodies? My understanding is that, when kinematic, ...
13
votes
6answers
6k views

How do dialog trees work?

That is, what is connected to what and how to move between lines of speech when a sub-conversation ends? If you have any examples of a basic dialog tree in C#, please post them.
1
vote
1answer
116 views

Distance based item interaction

I'm having an odd issue in my implementation of distance based object interaction in Unity. Basically it's a simple "Press [key] to [search/pickup/open/etc]" function which requires the player to be ...
1
vote
1answer
69 views

Trouble GamePad input on iOS but works perfect on Android

I am having trouble getting input from on iOS devices (iPhone 6 Plus and iPad). Here is my code, if (Input.GetKey (KeyCode.JoystickButton14))// A { chr_show = "A"; } if (Input....
3
votes
2answers
818 views

Unity 2D Alpha cutout layer for Sprites

I'm trying to make a simple Fog of War effect for my 2d game, similar to these: . I want to have a sprite layer of black and then have a sprite to cut out itself from the black layer, leaving a ...
2
votes
0answers
22 views

Unity3d Isometric moving forwards

I am making an isometric game using unity 3d and 3d graphics. I have been able to figure out how to create and isometric camera that follows the player, and a basic isometric moving script for the ...
1
vote
0answers
27 views

How can I get UI element over which pointer is in Unity3D?

I can detect if mouse is hovering any UI element by EventSystem.current.IsPointerOverGameObject(). But how do I know which GameObjest it is exactly? I have tried: if (EventSystem.current....
1
vote
0answers
24 views

How can I create click and drag for a 3D Jenga game in Unity?

Essentially, I am trying to create a game that mimics Jenga. Right now I have made it so that the blocks collide with each other and have gravity, everything works very well. The one thing that I am ...
1
vote
0answers
24 views

Top down controller script trouble

My game features a top down camera that follows the player as he moves via virtual joystick on a cellphone screen. I want the movement of the player to always walk forward and the direction will be ...
1
vote
0answers
14 views

How to add all MonoBehaviours of Scene into the List?

I've read an article 10000 UPDATE() CALLS. Author uses UpdateManager. It has Update method which calls Update method in all of other MonoBehaviours of objects. It works faster than calling Update ...
3
votes
2answers
174 views

Touch taps only on very short flicks on Win7 with Monogame

I have an application on win7 which needs to support touch and mouse input using monogame. But reading touch taps proves to be a very hard thing. The TouchPanel is initialized like this: TouchPanel....
1
vote
0answers
21 views

Unity 2D animation running partially

I have a 2D skeleton animation of human walk cycle - which is fine. I am trying hard to code that should STOP only hands animation but legs should not (on a player input - for example on space bar ...
1
vote
0answers
27 views

Game logic implemented using TPL / async / await, and performance of it

I'm working on a game, and as a typical game (here using Monogame) it uses frame based approach, where all logic happens in Update() method called every frame. As a consequence, any sequential logic ...
2
votes
1answer
52 views

How can I create a copy of an object in Unity?

I'm new to unity. How can I make some copies of my GameObject in Unity by scripting? I have tried this by the way: public GameObject stone_3; void Start () { for (int i = 0; i < 10; i++) ...
2
votes
4answers
417 views

Move ball based on direction of force?

I'm trying to make a ball that will move in the direction I push it from, and later pull it to me based on where the player is standing. using UnityEngine; using System.Collections; public class ...
1
vote
1answer
41 views

UI 5: Slider Pressed

I am using the UI slider from Unity 5 and would like to display a text every time the handle knob is touched/pressed. My understanding is that my script should extend some Event System interface. ...
1
vote
2answers
42 views

Camera relative movement is pushing into/off the ground instead of parallel

I'm building upon roll a ball tutorial in unity, and I have managed to rotate the camera around the ball just fine with the code below. But there's one problem. In this code, when I add force to the ...
1
vote
1answer
35 views

convert clock input into 24 hour format

I have stuck in a logical problem I have a third party package of DayNight. It takes hours input(24-hour-format) to show dayNight effects in scene My code is to transform 12 hours clock cycle into 24 ...
1
vote
0answers
38 views

Position values magically flipping signs

I'm trying to make a 2D sliding puzzle game (like 15 puzzle). My main problem is getting the squares to stop just before they touch. I don't want to use colliders because I'm scared they might pop out ...
1
vote
1answer
115 views

How to handle collision detection

So the way that I am doing the movement for my game is that you can left click a unit (which is just a rectangle object), and then it is selected. While it is selected, you can right click and that ...
1
vote
1answer
80 views

Rotation Continuity help

First the issue im having: Basically its the fact that the angles of a circle aren't continuous, they rise from 0 to 2pi then immediately fall back to 0. I want to make a game where the player ...
1
vote
1answer
48 views

How do I toggle color writes in SlimDX 11/Direct3D 11 with FeatureLevel 10?

I'm having trouble setting the RenderTargetWriteMask field of a RenderTargetDescription struct. I simply want to toggle color writes but every time I try to enable the the color writes are changed ...
1
vote
3answers
324 views

Arrow key control on winforms RichTextBox

I am making a faux console using winforms for the game I am working on. Right now I am moving a '0' across the screen using the arrow keys. In order to provide fine grain formatting on the text, I ...
0
votes
2answers
71 views

Prefab Instantiates into scene, but when I store a reference to the instance it's null

I am instantiating and parenting two objects - the first is a Unity primitive and the second is a prefab cube (literally nothing but a cube made into a prefab). The direct instantiation of the ...
1
vote
1answer
527 views

3d Wall sliding collision

I'm working on collision for walls in my game and the way I currently have it I get stuck walking into a wall. I'm trying to make my character slide on the walls but still collide. My character moves ...
1
vote
2answers
45 views

Unity2D - collide with objects while moving to a position

How do I get my character to collide with other objects while moving to a position? All I've managed to do is change the position, it only collides if the character is not moving, it's like he is ...
1
vote
1answer
67 views

Why do I get an infinite loop created by a subtraction in Unity3D? [on hold]

Does anyone have a solution to this ? When I do the subtraction , it makes a loop that does not stop. if ((lamp.activeSelf == true)&&(test == true)) { money = money - 50; /...
2
votes
1answer
105 views

Raycasting from vertices is not working

I have two perpendicular planes in xz and yz like this I want to find the projection of the vertices of plane 2 on plane 1 using raycasting.The rays are hitting the plane but the log is showing ...
0
votes
0answers
17 views

Toggle between function in unity [closed]

I want to toggle between function with the left mouse click. So basically, I want my the screen to start with displaying func1(func1 is activated), then when you press the left mouse buttonfunc1 gets ...
4
votes
1answer
101 views

How can I add a new item to my enum list in the inspector?

I have a list of enums. I want to add a new item to it without scripting to make them more easily modifiable for game designers. I made an inventory system and I want to define the type of an item. ...
0
votes
1answer
46 views

Creating 3D gravity in zero-G tied to mass in unity with c#

As a total beginner, I've been working on a patch-job script for a gravity mechanic in an open space sim, I want to derive all my objects from this "Block ALPHA" object and its' set of variable ...
-1
votes
0answers
32 views

Best way to implement card effects for a TCG [closed]

So, I have been wondering for some time how people code different card effects for the various TCG card games that are available now. After thinking about how I would implement this, I came up with ...
0
votes
1answer
20 views

Playing an animation all the way through with one quick keypress with Mechanim Unity

I have an if statement inside of the Update function that is only called if three other conditions are met. The problem is that right now the function sets a boolean to true which causes the animation ...
3
votes
1answer
585 views

NegaScout with Zobrist Transposition Tables in Chess

I'm trying to put Transposition tables into my alpha beta scout. I do see an incremental speed boost I think toward mid or late game, however, even with a table size of 1-2GB, its may or may not be ...
1
vote
2answers
34 views

Replace PolygonCollider2D with MeshCollider at runtime

I am using a PolygonCollider2D to load in points for a MeshCollider at runtime, but am having issues switching between the two at runtime using good coding practices. This is a simplified version of ...
1
vote
1answer
97 views

Programmatically change combination of sprites

I am a total newby to unity and cannot figure out how to achieve the following: I want to show a picture composed of different sprites. E.g., a pen with four binary features: the pencolor (black or ...
-1
votes
0answers
41 views

Why does my code crash on sign-in with Google Play? [closed]

I just updated GooglePlayGames plugin for Unity. My code worked fine before I updated the plugin but now my game crashes on sign in. public class Signin : MonoBehaviour { void Start () {...