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

1
vote
1answer
50 views

How to make enemies randomly choose a path and then come back if wrong one?

So I'm making a 2D Tower Defense-game in Unity with C# where the enemy has to go to the base, but can go to the wrong path randomly and then turns around when the road ends. How can I achieve this?
2
votes
1answer
309 views

Modularization in a project

I'm writing a C# game in Mono, and I want the game to be as modular as possible. I've started by writing the whole Item (inventory) System of the game in a seperate .dll library But I've hit a problem....
0
votes
1answer
25 views

Unity2D - How to destroy my Instantiate particle system

I'm having trouble trying to destroy my Instantiated particle system, I can only destroy my gameobject using UnityEngine; using System.Collections; public class meteor_destruction : MonoBehaviour { ...
3
votes
1answer
257 views

Local avoidance together with any-angle types of A* Pathfinding

Recently I have been implementing the Block A* any-angle path-finding algorithm in a project I have, for which I need extremely efficient results due to the large number of NPCs. However, I still do ...
3
votes
2answers
1k views

Unity2D: Automatic scaling of camera and sprites

I'm working on a point-and-click adventure game using Unity2D for mobile devices and possible PCs and I'm trying to wrap my head around supporting devices with different screen sizes and aspect ratios....
1
vote
1answer
77 views

How can library classes access SpriteBatch?

I have a spritebatch in my primary game component in a game project: public class GameRoot : Game { private SpriteBatch mySriteBatch; public SpriteBatch MySpriteBatch { get { return ...
1
vote
1answer
51 views

How to make a temporary collision?

I have a key and door system working, the character(ball) picks up the key and when it is within the collider it sets the text("press E to open") on the screen to active so that they can open the door....
1
vote
1answer
138 views

Unity Collision Doesn't Work when Two Players Instantiated

I am using Unity3D and I have a problem. I have a script which instantiates the player gameobject once you are connected to the server. I also have an attack script. When there is only 1 player on, ...
0
votes
2answers
54 views

Why does accessing ParticleSystem.IsAlive() raise this error?

I am trying to record if my particle system IsAlive with: GameObject prefab = Instantiate (Prefab, myPosition, Quaternion.identity) as GameObject; Component ps = prefab.GetComponent<...
0
votes
1answer
33 views

Unity detecting edge of mesh or end of mesh

I'm trying to create procedurally generated tiles and I've reached a point where I need to figure out the boundaries of the mesh or the outer vertices of the mesh. RaycastHit hit; if (...
2
votes
0answers
40 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 ...
0
votes
1answer
74 views

Need Help With My Script And Animator. I am encountering a few bugs with it

Okay so I have created a player archer character which when he using the arrow keys, faces those directions and upon hitting space when in that direction, the bow attack animation is played. The code ...
0
votes
1answer
169 views

How to get a position from a radial distance and angles?

I have a radius and the 2 angles for northSouth and eastWest rotations in degrees. I need a Spherical position or a cartesian position (I have code translate one to the other) Where a position is ...
0
votes
1answer
35 views

Why object spawn duplicate and double sides.?

I have a script, I am using this script to instantiate new path and also wall (as border) to generate new path and wall. Before some time all scripts work fine. but at this time my player enter in ...
0
votes
3answers
289 views

How to access multiple 2DTexture which is assigned in Unity3D inspector panel created by an array in C#?

I am making a puzzle game, i made 5X5 cube, lets take example of orange. very left column is orange, upper with orange dot is static and lower with orange dot is also static. inbetween there are 3 ...
0
votes
0answers
12 views

How to use OpenCV/EmguCV with Unity3d

I am beginners to OpenCV and want to use with Unity3d. I found different costly packages at asset store but i can't use it i.e., I want to try it myself and found EmguCV that provide openCV wrapper in ...
-3
votes
3answers
61 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
1answer
24 views

Unity - How to serialize / show private fields and custom types in Inspector?

By default, Unity only serializes public fields. How can I serialize private fields and custom types to show them in inspector?
12
votes
6answers
1k views

How to properly differentiate single-clicks and double-click in Unity3D using C#?

What I am trying to understand and learn here is a very basic thing: what is the most general and most polished way to properly differentiate single-clicks and double-clicks for the 3 main mouse ...
1
vote
1answer
102 views

C# OpenTK Text rendering

I've been looking everywhere for a solution on how to render/draw text for my 2D OpenTK-based game. Been trying quite a few QuickFont ones without success (either a AccessViolation exception or text ...
3
votes
1answer
48 views

How do I move a unit one grid-square-width per button press in Unity3D?

I'm learning Unity. I'm making a 2D top down Frogger-esque game. I was wondering how you would go about making the player move x pixels per button press. I have this code to move him, currently with ...
3
votes
1answer
94 views

Problem disposing content from a screen's content manager

I have a problem with my game. I am using multiple classes for different screens, for exemple: Main Menu is one screen, When playing is another, and so on... I decided to use multiple ...
-1
votes
1answer
22 views

Unity: Build on specific wall of the box

I'm trying to program game similar to Minecraft - you build environment from cubes. So far I found that Unity has a function which tells if mouse is over a box collider. I need a function which will ...
2
votes
1answer
216 views

Store Player Stats

My character creation order is: Select Race, Select Class, Assign Bonus Stat Points, Customize and Name the character. Because I am using Unity's UI components I am using scripts attached to empty ...
1
vote
1answer
48 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;...
8
votes
1answer
137 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
33 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
227 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
116 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
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
59 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
319 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
22 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
117 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
825 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 ...
1
vote
0answers
23 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
29 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
28 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
25 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
16 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
176 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
22 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
53 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
420 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 ...