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
83 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 ...
11
votes
5answers
16k views

How to change Gravity towards certain object in Unity?

I have two spheres in Unity. One is 1000x in size other is 1x in size. So I want the smaller sphere to be attracted to bigger sphere. So how do I do it. I know that it can be down through gravity ...
2
votes
1answer
490 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 ...
0
votes
1answer
51 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 ...
0
votes
1answer
53 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 ...
-1
votes
1answer
36 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 ...
4
votes
1answer
442 views

How can I mask this CanvasRenderer?

I'm creating a text box that allows for selectable text, based off of Unity's InputField. An issue I am now facing is that the selection highlight does not respond to masks (The parent has a mask, but ...
0
votes
0answers
16 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 ...
1
vote
1answer
39 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
1answer
259 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 ...
3
votes
2answers
236 views

Mock Collision Object in Unity

Problem: I'm trying to set up some tests with mock collision objects, but i cannot construct collisions with custom objects. What I'm trying to do: Collision2D col = new Collision2D(); ...
0
votes
1answer
144 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
4answers
314 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 ...
4
votes
1answer
31k views

Change the sprite of a Object in Unity

Inside the script code of the the hero(object) I want add the possibility to change its sprite. So the player hits the space button and the sprite changes into the other sprite already added to the ...
0
votes
1answer
55 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 ...
0
votes
3answers
91 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
19 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
1answer
333 views

What is the proper way to get input from the motion controllers touch pads?

I've been trying to figure out how to get the inputs from the touch pads on the motion controllers but have yet to find out how to do so. Initially I tried doing the following (as it was how I ...
-1
votes
1answer
35 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 ...
3
votes
1answer
89 views

How to do an anti sway bar for a car in Unity 5?

I have researched some examples of anti roll bars for Unity but they are all for unity 4 and bellow so they do not work in unity 5. Can someone please assist me in making an anti roll bar script in C# ...
0
votes
2answers
40 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 ...
6
votes
0answers
190 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 ...
2
votes
1answer
1k views

How do i define array in shader's constant buffer with C#?

I am using SharpDX to render 3D graphics and i cannot get to work constant buffer in my shader since it contains an array. Currently it looks like this: cbuffer cb0 : register(b0) { matrix ...
0
votes
1answer
489 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
31 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 ...
0
votes
1answer
115 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
1answer
32 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 - ...
0
votes
0answers
24 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
303 views

GUI.DrawTexture problem in Unity

I'm having a problem with GUI.DrawTexture() and I'm looking an alternative function to draw 2D Texture Images. The problem I have is that my textures draw above all other objects and when my camera ...
0
votes
0answers
13 views

Rotation towards the movement direction of an object [duplicate]

I have camera which is moving on spline one by one. One complete camera path (spline) consist of several spline and I moving my object on that spline using MegaShape Script package. I have LookAt my ...
0
votes
3answers
277 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 ...
2
votes
2answers
94 views

Start Menu Does not Work

On starting the game, a basic startmenu should load. startScreenUI is the background image, and startUI is the buttons for "play" and "exit". I set Time.timescale to zero in Awake() so that the time ...
0
votes
1answer
31 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
1answer
73 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 ...
0
votes
1answer
36 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.
2
votes
2answers
648 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
votes
2answers
23 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. ...
0
votes
3answers
322 views

How do I make so when user moves the camera it doesn't go beyond the scene borders in Unity3D?

How do i make so when i move my camera, it doesn't go beyond the border of the canvas while playing. This is the script i use to make the camera move: if (Input.touchCount > 0 && ...
1
vote
1answer
24 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 ...
0
votes
2answers
64 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
1answer
68 views

How can I access the translation part of a skinned Model object's bone transformation?

I have an animated Model, which I process with the SkinnedEffectProcessor. How I can access translations of that model during animation? It's always a BoneTransform I am working with, but I'd like to ...
1
vote
1answer
431 views

XNA (BEPU) Physics Performance

Im using XNA 4.0 with the BEPU physics engine v1.2 and I have encountered some performance problems on Xbox. Im not sure if the my mesurements are an expected result of the Xbox (with alot of dynamic ...
2
votes
1answer
207 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) ...
1
vote
1answer
23 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
1answer
26 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 ...
3
votes
2answers
833 views

Control animation using animator control class

I did a sample existing code to control animation using animation.I dragged and dropped a character into the scene then I added a Animator to it and added the animator controller.Below I have given ...
0
votes
2answers
44 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 ...
3
votes
1answer
74 views

Lidgren not starting server properly

I have a server set up for my game with Lidgren, and it works well when I have it set up on one machine, but if I try to run the server on another machine, I am unable to connect from other machines. ...
0
votes
1answer
85 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. ...