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
votes
1answer
81 views

How do I show the ranking images at winning post?

I am working on a racing game in Unity3d and I have to show the rank as the winners touch the winning point. As the winners reach at the winning point the image of the winner number should pop up for ...
5
votes
2answers
777 views

Is there an efficient way to identify in which run-time generated room a character is, in a non-grid 3D environment? How?

Here is what I am trying to implement. I wrote a script that allows the player to place walls during run-time, in non grid-based 3D environment (walls can be diagonal with rotation increasing/...
-1
votes
1answer
63 views

Unity 5: Stays slow after code runs

Hi guys :) I have just tweaked the FPSController Script so that when you are below 6y, you are slower and gravity is a little weaker. This is to simulate underwater effects, but when you come out of ...
1
vote
2answers
270 views

Position UI.Button to mouse position

This has been discussed a couple of times, but I didn't find any solution: I want to set the position of an UI.Button to my mouse position. I can get the mouse position like this: Vector3 ...
1
vote
1answer
198 views

Most efficient way to calculate angle between two line-segments that do not necessarily touch each other

Although I found answers on calculating angles from vectors, I didn't find a specific way to calculate angles between line-segments that do not necessarily touch each other (I say "not necessarily ...
4
votes
3answers
170 views

How to test for adjacency?

I need to come up with a better way to test for adjacency in a grid environment. Imagine that the blue is water, the green is land, and the red dot is a character. What I need to do is efficiently ...
2
votes
1answer
592 views

unity - problem in limiting rotation of object?

I am trying to make a game with unity. In this game, player uses mouse to rotate a container or box around x and z (rotate to left and right and also toward the camera and opposite). I used below ...
1
vote
2answers
153 views

Unity 5 C# collision problems

I want to make the built-in FPS controller collide with an object and switch a boolean to true. Here is my code: public static bool WellGUIOn; // Use this for initialization void Start () { ...
2
votes
1answer
67 views

Storing visibility graph for path-finding: do redundant and non-visible pairs of points have to be saved?

Using C# in Unity, I have recently implemented an algorithm that determines during run-time the visibility graph of a given scene in my game project (visibility between corners of obstacles). Now I am ...
3
votes
1answer
104 views

Vector3.MoveTowards on y axis only

I am making a final boss fight area and it has multiple platforms that go higher and higher up, I need the boss to follow the player up and down. I have a script that has the boss the follow the ...
1
vote
2answers
79 views

List of Lists for sending paths from client to server? [closed]

I have a client server scenario and I'm looking into distributed AI. I want the server to move x amount of ai characters around a map by pathfinding and then send the x amount of paths to the client ...
1
vote
2answers
81 views

Interaction between GUI and character(s)

This is more a question about architecture. Not sure if there's a right or wrong: Let's assume I have some gameobjects: GUI: A menu containing some elements like "Go to position". It's opened when ...
1
vote
2answers
173 views

How can I minimise memory thrashing when doing vector math in C# or C++?

I'm doing a lot of 3D math in my game engine loop using typical classes like Vector3D, Matrix4x4, Plane3D, etc. Currently every operation causes a new object to be created for the result value. The ...
1
vote
2answers
82 views

Unity2D - Save everything in a scene before loading another and come back to it?

So I have am into this endless runner thing where everything is generated randomly from prefabs. Okay cool! But I am currently working on a bonus collectible which takes the player to another scene. ...
2
votes
2answers
608 views

Board like strategy map

I want to make a strategy game like Risk. I want to use C# for the mechanics and Unity for the graphics. My problem is that I don't know how to create the map itself and integrate it with C#. I don'...
1
vote
0answers
87 views

How to make dynamic DOF from mouse position in Unity 5?

I found a video a while ago for how to make a dynamic DOF in unity. It fires rays from the camera and positions an empty at the location that the ray first hit. How can I change this so that it doesn'...
3
votes
2answers
623 views

Implementing a 4x4 Game Board

I struggle with efficiency in code, and I want to start my game off on the right foot. I have a game that I'm making a 4 x 4 map of 'tiles' that a user can build their 'town' on. To keep track of ...
1
vote
0answers
85 views

How to make lens flare ignore layers work with first person character in Unity 5?

I have a simple lens flare on my directional light (sun) and I would like the flare to only be visible when the sun is directly visible, naturally...But right now with the default ignore layers, the ...
2
votes
1answer
216 views

Keeping an object constrained to a 2d radius based off of the camera

A few weeks back I posted a question about keeping an object on the screen. What I would like to do now is clamping an object around a 2d radius based on the camera. I'm need this for a reticule ...
1
vote
0answers
66 views

Open Borders in Fluid / Smoke Simulation

I am trying to adopt a fluid / smoke simulation based of the source files of this video to my needs but came across a few problems when trying to make it open at the borders (flows into the void). ...
3
votes
2answers
128 views

Most efficient way to get the world position of the 8 vertexes of a Box Collider (C#)

What I am looking for is the most efficient way to get the world position of the 8 vertexes of the Box Collider of a freely rotated Gameobject. I cannot use collider.bounds since object is rotated, ...
1
vote
0answers
41 views

Detecting the two Vector3 that determine the bottom-edge of the side of a box-collider that had collision (with C#)

So, I understand that plenty of questions have been posted on how to detect which side of a Box Collider had collision. However, what I am trying to achieve is a little different. I want to find out, ...
2
votes
2answers
145 views

preventing a camera from getting stuck inside a mesh in Unity

I've a 3rd person camera similar to Mario64. Currently, I'm working on preventing the camera from getting stuck inside a mesh. The goal is to move the camera overhead. This much trickier than I'd ...
3
votes
2answers
824 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 ...
2
votes
2answers
415 views

How to fix flare in unity?

I have a simple sun flare that I would like to appear on my directional light (sun). However I cannot see the flare, I have tried setting the ignore layers to everything and checked and double checked ...
4
votes
1answer
322 views

How can I set 3d sound to my game in unity5?

I have been working on a racing game in unity5. Now I want to set 3d sound so that if the game objects are far away from and coming towards the camera then it sounds like began to attenuate and then ...
3
votes
1answer
146 views

Distance travelled by gameObject and behavior depend on device's performance?

The distance travelled by my gameObject and behavior depend on my device's performance. If the device is slow for example, it takes longer to accomplish a specific task, thus travels at a smaller ...
2
votes
1answer
126 views

'Ball.rigidbody' hides inherited member 'Component.Rigidbody'

I have some understanding of c# and I am new to unity. I am currently making a 3D project which use the Rigidbody component on the ball object. When I use following code: public class Ball : ...
0
votes
2answers
108 views

Optimal way to find point D that lays at the perpendicular line between point A and line BC

I am trying to write a script in C# to find the position of point D in 2D space in a specific scenario. I know the (X,Y) position of point A, which never happens to be on the line that contains the ...
7
votes
2answers
1k views

Pointers in C# Unity

Hey I've just learned about pointers recently and am wondering how I can use them in c# (I just learned about them in c++) in unity. I do have some questions though. Pointers use low level ...
1
vote
1answer
189 views

Ray & Segment Intersection

I'm writing some code to check intersection between all of a rectangles segments and a ray. It will sometimes use the Left and Right side of the rectangle as the closest face hit (face DA & BC) ...
0
votes
3answers
464 views

Unity FP Character Can't Look Vertically

I have a FP Character and well, it can't look vertically. Its happened about 3 times now, each time I just replaced it with the standard assets prefab, first few times it worked fine, but then after a ...
0
votes
1answer
1k views

Unity 5 C# - onClick.AddListener in a foreach loop using lambda expressions

I'm trying to dynamically create Unity 5 UI buttons that each set a global variable decision_id to a different value when clicked. The problem I'm having with this implementation is that they all ...
1
vote
0answers
845 views

Colliding without physics in Unity: is it possible to put OnTriggerEnter in the moving character?

My main question is: is it possible to put OnTriggerEnter in a script that goes attached to the moving character instead of to trigger area/object? Let me explain my exact need. I want to detect the ...
1
vote
1answer
117 views

Transform.LookAt rotates the sprite and collision not triggering

I've applied the below script to a gun object to instantiate bullets to the direction of the mouse position. The bullet collision is not getting triggered since the bullet has been rotated. How to ...
0
votes
1answer
71 views

Fixing strange artifacts in an HQX shader

I'm having an issue implementing an HQX filter that I found in the LibRetro GitHub repository. LUT texture was obtained here Shader file was obtained here (I converted it to compile in MonoGame with ...
1
vote
0answers
71 views

Selecting Dictionary item based on custom classes instead of keys

I am attempting to write my own path finding code for a game I'm working on that will implement a form of the A* algorithm. I store my nodes of the path finding system as a class called nodes and add ...
7
votes
2answers
279 views

How do I create a draggable object which snaps to obstacles in the way?

I bring yet-another-drag-with-mouse question (I am using Unity with C#), but with a less common particular detail: the existence of obstacles in the middle of the way trough which dragging occurs (3D ...
1
vote
1answer
72 views

Find x and y position with angles in 3D world

I'm actually creating a Tracking Camera (or 3rd person camera), and to do so, I used two angles (X and Y) for the rotation of the camera and an other floating value for the distance between the target ...
2
votes
1answer
68 views

Assigning Objects when duplicated in the editor?

I'm wondering if there is a way to have an Object when duplicated in the editor assign a GameObject variable to the newly duplicated version of itself. Is there an option in Unity or do I have to code ...
3
votes
3answers
606 views

Unity C# - Raycasts, How to Ignore Triggers?

Let's say I have a Raycast, but I don't want it to collide with any triggers. I don't want to change the Project settings since that's a little inflexible. How can I have a Raycast ignore any ...
1
vote
3answers
139 views

What's the most efficient way to find the position of a point in relation to corners of a rectangle despite rectangle's scale

I am struggling to achieve the following with C# (in Unity). I need to find the position of the points that lay at a given distance (let's say 1m) from the corners of a rectangle, in a way that the ...
1
vote
0answers
182 views

Best practices for client-server communication in an online Android game

I'm developing an online RPG game for my "Object-Oriented Programming" module laboratory project. The client part must be written in C#, also using Unity 3D as a graphics engine. The problem is that ...
0
votes
0answers
414 views

Unity 3D - Changing emission color in realtime after export doesn't work

I am using the following code to change material's emission color in realtime: Color selectionColor = new Color(0.3f, 0.2f, 0.0f); void Start() { gameObject.GetComponent<Renderer>()....
4
votes
3answers
845 views

How can I detect if a gameObject has collided with two other specific objects at the same time?

How can I detect if a gameObject has collided with two other specific objects AT THE SAME TIME? This is what I intend to do but it does not work: void OnCollisionEnter (Collision col) { if(col....
0
votes
0answers
196 views

First person view camera control using joystick in Unity3D

Can anyone give me any tutorial about how to program a first person camera control using joystick in unity3d? I've been searching for this for a long time and I'm out of depth unfortunately. I only ...
1
vote
1answer
714 views

Monogame shader not working

I'm trying to use this this tutorial in monogame, but the effect does not work, only renders a black screen. Everyhing by itself renders just fine, I looked at the render targets if they get drawn to, ...
2
votes
3answers
527 views

Camera follows player but how to stop camera moving when player moves

The player is moving automatically diagonally down the screen, and I have the camera as a child on the player. I would like the camera to always be following the player (who sometimes slows down / ...
0
votes
1answer
103 views

Most efficient way for nested loop to not repeat a value of parent loop in pair-wise structure (C# or Javascript) [closed]

It's hard to choose the correct title for this question, so let's see if I am able to better convey here what I am in search for. If the title is too far away, suggestions are welcome and I can edit ...
0
votes
4answers
287 views

Is database necessary? [closed]

Hi I have studied c# for good few months and I'm at intermediate level at the moment. And few days ago I decided to make simple 2D Games like "Mr Jump" after studying Unity. So my question is as ...