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
79 views

Raycast Flashing problem

Can anyone tell me what is wrong with me code ? If you can see, whenever the player is in range of the raycast. The enemy turns red. But for some reason. Even when the player has meet the requirement ...
0
votes
1answer
17 views

(Efficiently) Generate Unique Random Numbers

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 ...
2
votes
2answers
135 views

Jumping higher when the player touches a trigger collider in Unity

Im using Unity engine to create a 2D platformer. My character can single/double jump, this works fine everywhere except when i am in range of a collider with a IsTrigger set to TRUE, then my character ...
0
votes
1answer
11 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 ...
0
votes
0answers
35 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 ...
1
vote
1answer
93 views

How do I let a game support different rule sets?

I'm making a MUD game engine that supports D&D , Pathfinder and other tabletop-RPG rule sets. I am starting to build out how characters interact with the world (e.g. dialog, battle, searching for ...
1
vote
0answers
52 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 ...
2
votes
3answers
45 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
20 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 ...
2
votes
1answer
69 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 ...
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 ...
1
vote
2answers
75 views

MonoGame 3.3 Font loading

Is there any way to have fonts in game without making a separate Content Project and adding a .spritefont file in the new 3.3 Monogame? You can now load other resources directly from the Content ...
0
votes
1answer
70 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 ...
0
votes
2answers
49 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 ...
-1
votes
1answer
28 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
32 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) ?
0
votes
2answers
152 views

How to stop objects pushing each other away on collision?

I'm creating something along the lines of Super Smash Brothers. There's a problem with the collision between the two players and projectiles. We have rigid body on the characters and projectiles and ...
0
votes
1answer
66 views

How do I make this block go back to the left with another click?

This is the script I've written so far which makes the block move from the left of the screen to the right on a mouse click. What I want to achieve is for the block to move back to the left when I ...
4
votes
2answers
208 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 ...
3
votes
1answer
91 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 ...
1
vote
2answers
199 views

Spritebatch not working in winforms

I'm using the Winforms sample on the app hub and everything is working fine except my spritebatch won't draw anything unless I call Invalidate in the Draw method. I have this in my initialize method: ...
1
vote
0answers
34 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?
0
votes
1answer
85 views

MonoGame InstancePlayLimitException on Windows w/ OpenGL

Why am I getting the InstancePlayLimitException when playing several SoundEffects per second despite there being no limit unless programming for mobile? It occurs after only a few seconds of repeated ...
2
votes
1answer
28 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
29 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. ...
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 ...
0
votes
1answer
91 views

StartCoroutine inside TriggerOnEnter2D isn't working

I am new to this, but I need help with a CSharp script. I need to collide with the desired object, pass the game to be 1.6 in TimeScale. After passing 8 seconds in the game, change back to 1 ...
1
vote
1answer
84 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 ...
0
votes
1answer
24 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 ...
1
vote
1answer
57 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
41 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
57 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
94 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
2answers
921 views

Set new forward directions based on camera position [duplicate]

I have a 3rd person camera which can rotate around the player. When I look at the back of the player and press forward, player goes forward. Then I rotate 360 around the player and "forward ...
0
votes
2answers
86 views

How to make instantiated objects not on top of each other?

I randomly instantiate game objects, to create a dynamic "sky map". But some planets appear on top of another ones. I'm trying to solve this problem with Collision detection and Colliders, but it ...
3
votes
2answers
763 views

C# - Separating Overlapping Rectangles

I'm trying to separate an arbitrary number of randomly sized rectangles, while still keeping them snapped to the grid, and somewhat packed together nicely. The goal is to start with something like ...
0
votes
1answer
78 views

How to find the closest point on a plane

So I have this terrain with a perpendicular plane setup, now I want to move the vertices of the plane to their closest resp. vertices on the terrain. I made a drawing to illustrate my thoughts. ...
0
votes
1answer
37 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
73 views

About Developing Games [on hold]

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
38 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 ...
1
vote
2answers
72 views

Event handling on own UI implementation in XNA

I´m creating a game in XNA with my own UI and its controls/components. Currently I have some problems with the event handling. Let me tell me the way I do it right now. Every object is handles as a ...
2
votes
2answers
357 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 ...
2
votes
1answer
66 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. ...
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
0answers
17 views

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

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# [on hold]

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

Exception with Lidgren on Mac OS X [on hold]

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 ...
0
votes
2answers
49 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 ...