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
0answers
7 views

How to build Isometric tiled-based TD map [on hold]

I'm planning to create a 2D isometric Tower Defense game in Unity3D. I want to make it tile-based so I can split the tiles and give them different functions, ex I want the player to create different ...
0
votes
0answers
17 views

Creating a custom collider shape in unity, and performance concerns

I want to create a custom chaped collider in unity to create point-defense triggers for objects. I have a spherical collider that triggers for attacking objects that enter it already. However I want ...
0
votes
1answer
32 views

Make my Tower continously fire at enemy while inside collider?

So I've made a Tower script in c# that spawns a projectile that then fires at the enemy gameobject. However, because I'm using the OnTriggerEnter() function it will only fire as many times as ...
0
votes
1answer
26 views

Is transform.forward mutable?

Suppose I have a GameObject, and I want it's transform.forward to be facing up. Is it possible to change it as seen below? public class Main : MonoBehaviour { void Start () { Vector3 ...
0
votes
1answer
23 views

Unity Character jumping to the direction of the key pressed and not moving in any other until grounded [on hold]

I've been trying to figure this out for about 3 hours now, I have a first person controller script based on the Unity Standard Assets one and I'm trying to figure out how to jump to the direction of ...
0
votes
2answers
35 views

Character on spherical terrain

My game is played on a big spherical world. Made up of a big spherical mesh with sphere collider, with 'gravity' at it's center (gravity for objects is controlled trough scripts). Now if I put a ball ...
0
votes
2answers
51 views

(Efficiently) Generate Unique Random Numbers [duplicate]

Sorry my terminology is somewhat limited so I'll have to use more words to explain what I mean. In games that require critical hits, I've heard it's not good to generate a random number but instead ...
0
votes
1answer
25 views

StopCoroutine is not stopping my coroutine in Unity

I'm getting some attacking to work with my units and I noticed that the coroutines seem to start adding up even after the StopCoroutine(IEnumerator) as need called. I dug around on ways to perform ...
1
vote
0answers
22 views

Unity - C# - Angle tile not instantiating [on hold]

I'm currently connecting two rectangles with a 'L' shaped line. I have written the code so that it cycles for every position from one rectangle to the other and instantiates some gameObjects that ...
3
votes
5answers
80 views

How to “merge” multiple intersecting circles so that only the outer edges of each show?

In my RTS (In Unity) each unit or building has strategic circles in a similar fashion to SupCom. If you have multiple units or buildings selected it looks like the picture to the left. I want to make ...
1
vote
0answers
56 views

Recursive backtracking sometimes missing a tile?

I have a basic recursive backtracking alghorithm for a maze. It pretty much works but ocasionally leaves some tiles in the corners untouched. This is the recursive function: void ...
-1
votes
1answer
31 views

'The thing you want to instantiate is null' - unity error when instantiating

I have a Game Object called 'car' in my Assets folder. I have this code in C# unity to instantiate it. GameObject car; void Start () { Vector3 position = new Vector3(5, 5, 5); ...
0
votes
2answers
41 views

Instantiate a prefab on unity and make it appear at a specified coordinate

I have a prefab called 'road'. How can I instantiate it using C# script so that the instantiated object appears at coordinate (5,5,5) ?
4
votes
2answers
214 views

Callback on Derived Class?

How does Unity3D implement their system where if a class is derived from MonoBehaviour and has certain methods like Awake() or Update(), they are called accordingly? I want to do a similar system for ...
2
votes
1answer
83 views

Unity C# - My parameter 'campfireNew' does not exist (SetTrigger)

I'm trying to set a SetTrigger parameter to call a different sprite animation on a campfire. I tried this also with a boolean, yet again the same error. parameter 'campfireNew' does not exist. Anyone ...
3
votes
1answer
95 views

Structure for attacking in RPG

I'm going over different ways to implement attacking in a "dungeon crawler". What I have kind of abstracted out... There are 2 kinds of people, The Player, and the enemies, these are both living ...
0
votes
1answer
78 views

Using collectable items to change a gameobject Unity

I’ve been working on a 2D platform side scroller. I’m rather new to Unity and C#. Basically what I’ve achieved so far is a character which can collect Logs throughout the game and those logs are ...
1
vote
0answers
37 views

How can I get the pressure of a touch in Unity?

Does anyone know how to get the getPressure function from the Android API into Unity? Or is there another way I can access the pressure of a touch?
2
votes
1answer
31 views

Change Tag of Instantiated Clone

In my game there is a bird flying up and a stream of containers (baskets) is moving from right to left of the screen in the bottom. Baskets are being Instantiated on right and get destroyed when they ...
3
votes
1answer
30 views

Unity - C# - Overlapping Rectangles not separating

I am Instantiating a lot of Rectangles of different sizes (ranging from 3 to 18 units) and they all have attached this script, which should cycle through all the GameObject List which contains them. ...
10
votes
3answers
1k views

Looking for some insight on programming design for attacking and attack types in a game

So, I'm starting to introduce attacking to our 2D space RTS (This is in Unity, so it's component driven). Initially it was as simple as "enemy in range, damage applied". However there will be multiple ...
0
votes
1answer
26 views

xna - Render background and multiple sprites to a single texture

I currently creating a game and I am trying to render my background and a sprite to a texture. Currently I have the background being rendered to a texture. But I am needing to render both my ...
3
votes
1answer
63 views

Why does glBindVertexArray sometimes fail (but mostly not)?

Quick outline: Test program that loads and displays big (3k x 4k) 16bit gray scale images (ca. 32MB). Using modern OpenGL (eg. 3.3 or so) with shaders VBOs VAOs etc. Running on Windows with OpenTK ...
1
vote
1answer
89 views

Unity - Basic AI Enemy Follows Player - Prevent Flocking Of Enemies Together

I'm in the process of implementing a 2D top-down shooter game. I have a basic AI script that allows enemies to follow the player around. Currently it works fine for one enemy, but as soon as there are ...
1
vote
1answer
70 views

How to add a UI Text for keeping Score in Unity 5

My Problem is simple I want to show scores on my game. The examples on internet are good but in Unity 5 there are no GUI elements but instead these are now UI elements. I was following this example: ...
0
votes
1answer
44 views

Projectile Shoot three at a time

In my game there is a bird flying and on touch it throws different artifacts projectile downwards. And these artifacts should hit the containers moving right to left on the screen. Now if user keeps ...
0
votes
1answer
36 views

How to prevent constant adjustments form collision?

I'm try to clone a popular 2D platformer as a project. For both the player character and enemies, whenever I constantly check to see if they are walking on the ground or floating platforms, they ...
0
votes
1answer
63 views

how to Move Player on “Z” Axis 2D Movement

first im little new to unity..currently im working on 2D game mobile game.and im using Stranded Asset(Mobile) Single Joystick prefab to move Player..Currently my player move on X and Y axis. can any ...
0
votes
1answer
38 views

Input.mousePosition gives a NullReferenceException

I'm trying to Add raycast shooting to my player but when I get the Vector2 mouse position it give this error NullReferenceException: Object reference not set to an instance of an object This ...
0
votes
0answers
74 views

About Developing Games [closed]

I am starting from scratch for a project to develop a game but I wanna start with just mind games like memory game that shows photos on grid and then disappears, something very easy as step one So I ...
-1
votes
1answer
39 views

C# Unity3D - How can I use a INT from other classes?

I have 3 Objects Capsule 1, Capsule 2 and Capsule 3. Every Capsule has a script on it for health/damage. It also contains an int for hits and points. Hits should be increased by one for every bullet ...
0
votes
2answers
52 views

After sometime increase the speed of Instantiated object

This may look similar to "increase speed after every N seconds" type question but it's different because objects are being Instantiated and getting destroyed. In my start() method I'm calling a ...
0
votes
0answers
17 views

Recommendation for C# .Net 4.5 Game/Graphics book/resource [closed]

I'm looking for a book on learning graphics programming in C#. I asked this question in StackExchange, and they told me to go here. I hope this is the right section of the website family, as I don't ...
-1
votes
0answers
38 views

Call a method on many Objects in a List C# [closed]

I've got a list called wheatTiles it contains many Wheat objects. The Wheat class got a update method. Im doing this to cal the update method at the moment : public void Update() { ...
2
votes
1answer
69 views

Stretch the game to fit the game window, in Unity 5

(Desktop) I want to make it so that when the user re-sizes the game window, the game is stretched to fill the window. (Similarly, for Android) I want it to be stretched to fit the screen as well. ...
2
votes
2answers
361 views

How do I save and restore an int value with PlayerPrefs?

I am stuck on how to save the player's amount of money. When I build the game in the exe as soon as I shutdown the game my money value gets lost. I want this money to be saved. I am using the ...
0
votes
2answers
52 views

C# Unity3D FPS apply damage to an enemy (Weapon bullet)

I am kindly new to Unity3d and c# and I don't understand how I could let a bullet deal damage to an other object. I've seen a lot of JS tutorials but no for C#. I've tried to use them, but it wont ...
0
votes
0answers
26 views

Exception with Lidgren on Mac OS X [closed]

I was looking for a low level library for handling TCP/UDP sockets on the server for a long time. I came across Lidgren and I was thrilled - reliable and unreliable messages, sequences and unordered ...
-2
votes
1answer
33 views

Script to change size of a cube when pressing a button [on hold]

I am very new to coding and very bad at it. In my environnement there is a table, and i would like, after pressing a keyboard button, to make a cube appear. Then, by pressing another button, i would ...
0
votes
1answer
50 views

After collision of two objects change the sprite and move in its direction

I've searched a lot for this question but there was no answer that could solve the problem I'm having. I'm new to unity and a very naive developer.I'm making a game in unity using c# and it's like a ...
0
votes
1answer
42 views

Editing a new list of vector3's without changing the original list? (Unity) [on hold]

I just got Vectrosity for Unity and need to make a line of all the destinations for an object. Issue is that I need to use a single list of vector3's to create the line (as far as I'm aware). I have ...
0
votes
2answers
64 views

How to stop rotation every 90 degrees?

I was facing another rotation problem yesterday, that i managed to solve by rotating the object like this : transform.Rotate (speed * Time.deltaTime, 0, 0, Space.World); I tried almost every other ...
1
vote
1answer
61 views

Random, Infinite Terrain Generation [closed]

I'm trying to generate random terrain for my game (In Unity3D, C#). All I need is water and grass. No height to it (no mountains or hills.) I'd preferably like to do it by placing individual cubes. On ...
0
votes
2answers
34 views

unity2D Top-Dow Mobile rigibody2D

im using this code for my 2D TopDown mobile player movement.but when i move player With UI Image buttons player keep moving.it didnt stop.and also player starting of move he is very slow. the he ...
0
votes
1answer
53 views

Rotate Camera around GameObject in Unity [on hold]

Using Unity 5's new touch system, how can I rotate the camera around an object using touch detection, or "swipes"? I can do this using earlier versions of Unity, however the more recent version, Unity ...
0
votes
1answer
71 views

Delegation in unity C#

I have a game where I have balls bouncing and you shoot them. Since I need a way to end the level when the player shoots all the balls I though I would create a game controller script which will ...
0
votes
1answer
87 views

Unity 5 How Do I Set Text of Text Component of Input Field

How do I set the text of the new Input Field's Built In Text UI Object in Unity 5+? myInputFieldText.text = "Text Value I Want"; The code above does not work to set the text inside of a ...
1
vote
1answer
77 views

Tile Map Shader?

I'm trying to write a shader in unity that will take tiles from a sprite sheet and draw them onto a tile map. I'm new to shaders so this might be totally wrong, I think it might just be a math error ...
3
votes
1answer
146 views

How to correctly draw a line in Unity

I'm working on a game which requires me to draw a few lines from a single point that is more formally said Given point A with coordinates x,y I draw n lines where the i-th line has the coordinates ...
1
vote
1answer
90 views

OpenGL: Draw an arrow

I'd like to know how to draw an arrow to represent a vector position, length and direction. The issue is that I can't quite find an easy way to know the location and rotation of the triangle ...