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

How to combat exponential growth in sprite messaging?

In my 2D platformer game, I have a number of sprites moving around the world. When two sprites collide with each other, I calculate how deep the collision is and then call a virtual method on both ...
0
votes
1answer
75 views

Assign a ScriptableObject to MonoScript through code

Sample code: public class Item : MonoBehavior { public ItemObject item; //the scriptable object void Start(){ // do stuff} } Normally I would drag and drop the asset of the ...
0
votes
2answers
70 views

C# XNA :Snake Game, direction problem

I am trying to do a snake game in XNA but I have some little problems... I explain : The Snake has a direction (Enum Type : Haut(=up), Bas(=down), Droite(=right), Gauche(=left)) When the player ...
6
votes
4answers
3k views

Does “Object.ToString().GetHashCode()” return a truly unique character seed?

In my game I'm generating a character seed from a bunch of traits that the player chooses. The traits are all part of a Enum. In unity I've attached a script to a bunch of toggles. When the player ...
0
votes
1answer
56 views

Top Down Bullets will not move

I have a top down shooter. The player can move in the primary 4 directions, and follows the mouse for rotation. When I shoot, the bullets never leave the player, they just spawn on top of the player ...
1
vote
2answers
91 views

Get the difference between 2 matrices

Hi I'm using C# and MonoGame, and have the world matrices of 2 objects. I need to get the difference between them, so I can effectively parent the second object onto the first. The aim is to get to a ...
1
vote
1answer
52 views

How to check strings from multiple lines in one input field?

I need help with input fields. I already set the line type to 'Multi_Line NewLine' in inspector, but I have problem with submitting the string. Here's the code: using UnityEngine; using System....
0
votes
3answers
59 views

Problem with handling key input C#

I am attempting to make a game in C# in windows forms, and need for the character to react to key input. I have implemented a very basic code which changes the position of a picture box on key pressed,...
1
vote
1answer
40 views

Making Basic Touch Behaviors

I am trying to make Basic Touch behaviors for my game where i want to Pan Camera by Single finger touch. Zoom Camera by pinch With two fingers ofCourse. Rotate Camera by two fingers rotation. Rotate ...
0
votes
0answers
21 views

How do I figure out the view space coordinates for the screen extents?

I am trying to implement clustered shading which requires bounding boxes for each view sample. In short, I'm interested in creating a single bounding box that would cover all screen space. Here is my ...
1
vote
1answer
81 views

Quickly Converting RenderTexture to Texture2D in Unity3D

I have a screenshot preview at the end of the game's level. When I am loading the screenshot, it makes the game freeze for a moment. What may I do so there would be no freeze when I am loading that ...
1
vote
2answers
92 views

How do I implement level generation based on graph grammars?

I'm looking to do some pseudo-random map generation using graph grammars (graph rewriting). However, most of what I can find online on this is purely academic and, while helpful, doesn't have any ...
3
votes
0answers
25 views

Automatic audio segmentation and find the most energetic segments

What algorithm can be used for audio segmentation? I want to divide song to segments and find the most energetic segments (begin and end in seconds). It is needed for the rhythm-game. Examples: ...
0
votes
0answers
92 views

Player character not moving

i am trying to make an fps game but my character won't move. i have tried different scripts for more than a week. Any help will be appreciated. Thanks! using UnityEngine; using System.Collections; ...
0
votes
1answer
50 views

Make a person walk faster when standing on plane/panel in Unity?

Is it possible to make a person walk faster when standing on plane/panel in Unity without writing a lot of code? If so how? I am using the standard asset first person movement prefab.
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. ...
6
votes
1answer
159 views

How do I change a value gradually over time?

I'm using Unity3D 5-point-something, and I'm planning on making a game where the player travels through a hot, dry desert, and so the heat causes the player's energy to deplete. The object of the ...
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 ...
3
votes
1answer
87 views

Ability/Skill Data and Method Structure (C#, Unity3D)

So I've come to design my game which players will be having a unique set of skill or ability to come with. I can store skill name, mana cost, cooldown, etc in database which each skill have in common, ...
0
votes
1answer
40 views

How to remove terrain in 3d? [duplicate]

After the release of Minecraft I saw more and more rip offs of the game but some actually began to change it up a bit making the game have a organic look instead of the iconic blocky one that ...
1
vote
1answer
43 views

How do I make my indices anti-clockwise, so I can cull triangles in OpenGL? (immediate mode)

At the moment, I'm attempting a basic game engine in OpenGL using immediate mode. I'm trying to render a cube. Cube is a class with the vertices, normals, and indices. Here is part of the Cube class: ...
0
votes
1answer
59 views

How do I know what to do with incoming network messages?

I am programming a 2D game in a server/client architecture with C# and lidgren. When a client sends a message to the server, how does the server know what to do with that message data? The client ...
-1
votes
1answer
44 views

Moving object orientation toward its movement in unity3d [duplicate]

I have a gameObject (camera) which is moving on the spline. I want to set it orientation towards it movement. Means, object should need to see where it is moving. I some thing tried this but this is ...
0
votes
0answers
23 views

Load a specific sprite by name from a SpriteSheet with Resources.Load

The question is in the title. i want to avoid loading all the sprites from a sprite sheet into a dictionary for example so I can assign them that way. Is there a way to access the specific sprite ...
0
votes
1answer
72 views

Problem with Quaternions and Unity's Euler Angle Convention

So I want to rotate an UI-Element according to my magneticHeading, I just want to apply the magnetic heading to the z rotation in EulerAngles. So I tried to do so, which brought me to some weird ...
0
votes
1answer
33 views

Coroutine wrong Behavior when scene is loaded.

Ok so I have this coroutine : IEnumerator ShowCharTraits() { while(!hasPlayerChosen) { yield return null; traitPanel.SetActive(true); } ...
0
votes
2answers
41 views

My background stopped looping and is mushy and weird looking

My looping bacground texture looped perfectly, but maybe after building the project as an android project broke it? How can I fix it? using UnityEngine; using System.Collections; public class ...
0
votes
3answers
109 views

How to spawn enemies within a minimum distance of each other randomly? 2D

So I'm making an 2D infinite runner. So I try to spawn obstacles randomly in x-coordinate, but these just spawn most of the time in the same position and too frequently. generationPoint is just a ...
0
votes
1answer
50 views

LookAt different object smoothly in unity3d

As picture depicted my camera moving on path i want to lookAt bath different object smoothly. Currently have tried trasnform.LooAt(activePath.gameObject.transform); but it producing jerky result. ...
0
votes
0answers
21 views

Alternative to LookAt in unity3d [duplicate]

How does unity LookAt work i searched and found that this is how lookAt work but seems that it is not right? Vector3 lookPos = transform.position - trainFollowScript.transform.position;//...
1
vote
2answers
48 views

How can I select a object (canvas) with tag using Physics.Raycast?

I made this C# script, becase I want select a Button of the menu(canvas) for choice the dificulty of the game, but I don't want select with mouse I just want select with Aim, and I made this script ...
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 ...
0
votes
0answers
28 views

How to prevent object from moving when it's mesh/collider is being updated?

So I a made a script that lets the player grab a vertex, move it, and then update the mesh. To help prevent the player from trying to clip it through other objects I made it so the mesh/collider is ...
0
votes
1answer
61 views

Unity 5/C#/Scripting Switching Cameras

How can I switch cameras from First Person to Third person or from thrid person to first person. Like at GTA V you can switch the cameras. How to do this? Tnx for your time.
-1
votes
1answer
37 views

How do I allow my player object to continue rotating once it's met a clamped boundary?

I have a spaceship I'm moving around on the screen, when the player moves the ship, it rotates on its axis. However, when the ship meets a clamped boundary(on the x-axis) it abruptly stops. How do I ...
1
vote
1answer
45 views

Adding a Scriptable Object to the Scene

Suppose a Scriptable Object e.g. NewWeapon.asset with variables such as name, description, price etc. I 've also added a public GameObject weaponObject; so that I can drag and drop the 3D model ...
-1
votes
2answers
26 views

Why is my player object not being clamped?

I have a game object that has specific boundaries. However, when I have the object meet the boundaries, the object doesn't stop the way it's supposed to, it continues to move past the set boundaries. ...
1
vote
1answer
29 views

Quill18 Tutorial broken or Have I broken something?

Busy following a Quill18 Tutorial for a Tower defence game and It keeps giving me an error(NullReferenceException: Object reference not set to an instance of an object Solution 'TowerDefence') Now I ...
1
vote
1answer
60 views

Physics2D raycasting with a perspective camera and tilted sprites

So i ran into this problem today. I want to have a perspective camera and sprites that are rotated by lets say 1.5 on the X axis. The problem is that the 2D raycast does not work correctly, it returns ...
1
vote
2answers
57 views

Elastically Object movement in unity3d

I want to move an object towards the destination elastically. Currently I am using Vector3.Lerp it working to move the object, start with high speed and reached at destination with low speed but ...
0
votes
2answers
48 views

How can I get the assignment of an object back?

I have been struggling with this NullReferenceExpection error. When I don't add anything and just use this version of the code. The game adds a tower, upgrades a tower and takes money for it. It ...
1
vote
0answers
22 views

Accessing DualShock 4 motion sensor in Windows [duplicate]

I am attempting to access the accelerometer and gyroscope functionality of the dualshock 4 controller for implementation into Unity. DMGregory seems to have found a solution to this problem, my ...
0
votes
2answers
92 views

How do I handle parallel lines when looking for intersections?

I'm using the following method to determine the intersection point of two vector2: public static Vector2 LineIntersectionPoint(Vector2 startPoint1, Vector2 endPoint1, Vector2 startPoint2, Vector2 ...
0
votes
2answers
29 views

Moving towards and switching targets in Unity with collision

I have these nodes set up for a ship to move towards over time with out looking stops then repeats in a sequence. like so: 1 2 3 1 2 3 1 2... THE PROBLEMS i keep having either come from the ...
0
votes
2answers
82 views

Finding Game Object with Regular Expressions

Is there a way to use a Regular expression in the GameObject.Find() method? I'm making a checkers game and I've got pieces named Red Piece (x,y) and White Piece (x,y) (where x & y are actual ...
3
votes
2answers
211 views

Bullet holes on curved surfaces and corners

So right now I am making an FPS game where the gun creates bullet holes (plane with texture) on impact, but there is a problem with that, if I shoot at the edge the plane will stick out and also ...
0
votes
2answers
145 views

Why are my click events being fired many times for every click?

I am working on a game in unity where a user will click a button to gain coins and clicks over a lifetime of clicking the button but the code is making the clicks go up by a lot instead of just 1 each ...
0
votes
0answers
38 views

Unity 3D - Tags not Working

I have triggers that interact with planes, each individual plane has a specific tag. The problem is, that it seems to just detect all planes but one called "Middle Plane" Here is the link of the ...
1
vote
0answers
43 views

How to draw things on top of objects drawn in OnRenderObject()?

I am using Unity, here is the method in question. So I know this method draws objects after the camera is done rendering the scene. I have not come across a way in Unity to draw these objects in a ...
0
votes
0answers
31 views

Setting a destination to Nav mesh agent but the character moves around the edges of the walkable area

I created a character. Added character controller, rigidbody and nav mesh agent. On right click I get the position clicked using raycasting and set the hit point as the destination for nav mesh agent....