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
2answers
65 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
21 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
61 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
138 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
115 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
32 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 ...
0
votes
0answers
18 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 ...
-1
votes
1answer
38 views

GetComponent doesn't works

I have a Halo component on an object, on the same object I have a script, in the script I tried to get the Halo component, but the GetComponent< Halo >() doesn't work, it says that it can't be ...
0
votes
0answers
15 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 ...
0
votes
3answers
53 views

C# Integer limits for Scriptable Objects

I am experimenting with Scriptable Objects in Unity. In the following example how can I limit the range of accepted values? public class AScriptableObject : ScriptableObject { public uint damage; ...
0
votes
2answers
31 views

Tag for Moving platform

My character is not sticking on the platform when jumping on it but I don't know why. Here is the code: void OnCollisionEnter2D(Collision2D other){ if (other.transform.tag == "MovingPlatform") { ...
1
vote
3answers
56 views

Unity 2D, how to turn a bool true, after a set amount of time?

I have an enemy working to damage the player when they stay in collision for too long, at the moment, the enemy will attack about 30 times per second, however I want there to be a delay between each ...
0
votes
1answer
36 views

Is Update(GameTime) called before it's finished?

Code at the beginning of Update(GameTime) is being called over and over again, and code at the end of Update(GameTime) is only being called after a delay. Is Update(GameTime) called again before it's ...
0
votes
0answers
16 views

SharpDX.SharpDXException error when using vector as parameter

I placed a GraphicsDevice and width/height into the new RenderTarget2D parameters as it ask for but it keeps throwing an error. Does any one know why? Error: Additional information: HRESULT: ...
0
votes
0answers
14 views

Unity3D c# get animation playback position AFTER it is stopped

As title says, i'm having trouble determining playback position of legacy animation after it has normally finished playing or has been stopped. Here is a oversimplified demonstration: //how i get ...
0
votes
1answer
22 views

Making Scene at editor mode

On Button click at editor mode I am trying to make a scene of selected Hierarchy game-object but the problem is as i click the button new scene become upon and I lost the scene where i were ...
0
votes
1answer
58 views

Code for inventory function not working

I'm working on an inventory, and I've ran into some problems. Some code in my CollisionDetection class doesn't work properly. My CollisionDetection class contains functions that involve mouse and ...
1
vote
1answer
42 views

Global variables in a multiplayer environment

I would like to know what's the best approach to solve this problem. In a racing game, i need to create the final result chart. In a single environment i've tought something like: private string [] ...
0
votes
0answers
12 views

Script for Sprite Slicing works fine as a MonoBehaviour, but not as a normal class called in a Editor Script

I got a script for auto-slicing sprites from the internet. Link to the script. I made the script so that it is not a MonoBehaviour. Then i do this is my custom assets importer: private void ...
1
vote
1answer
60 views

Increase speed with each enemy destroyed?

I need some help with coding this idea: "For each Target destroyed, increase the Gunner's speed by (speed variable)". The idea is that the Gunner is automatically moving, and I want it to become more ...
-1
votes
0answers
28 views

Unity3D-C# - Resetting WaitForSeconds() on IEnumerator Coroutine

Mmmmm I dunno if I need to show code for this, ´cause this is more of a general question regarding a resetting of a StartCoroutine, or of the yield WaitForSeconds method. Because when I start the ...
0
votes
0answers
11 views

Problem with camera drag and draggable UI elements

I implemented my camera drag using the following method: if (Input.GetMouseButtonDown(0)) { dragging = true; followPlayer = false; oldPos = ...
-1
votes
0answers
25 views

How to throw an object Unity3d platform? This 2D

There is a platform revolving around its own axis (it works). We need to make sure that when you change the angle of the object platform rolled (it works), and the sudden change in the direction of ...
0
votes
1answer
43 views

Opentk hdr rendering with framebuffer white screen problem

I am trying to do hdr rendering with two shader programs: one simply draws a hdr texture on a fullscreen quad and the other one does tonemapping. I am trying either linear tonemapping colorOut = ...
0
votes
1answer
31 views

OnPointerClick not being called

I implemented the IPointerClickHandler in a script that runs on multiple GameObjects in my scene. I'm definitely missing something since the implementation is not being called at all. The objects are ...
0
votes
2answers
36 views

Script no longer working now that it is attached to a child object. Why is this?

So I decided I wanted to make this script part of a separate swap-able weapon so I made a child and put the script there. Before the script worked fine but now it won't work. The script works as ...
0
votes
1answer
21 views

Finer collision detection with multi-path Polygon2DCollider from Tiled2Unity

I'm in the process of incorporating Tiled2Unity prefabs into my code. Their exporter creates a collision object (shown below) that amalgamates the collider of each tile into a single Polygon Collider ...
0
votes
3answers
37 views

Unity inspector script - making it save the global variables for what it's creating

I have a script which initialises a bunch of child gameObject(s). I wanted all of this to happen outside of the game, so I created an inspector script which has a button which triggers the method ...
3
votes
1answer
76 views

Player motion and combo systems

Where do you usually implement player motion when going through the state machine of a combo system? An example, when player presses X+Y it must do an uppercut like movement (Like street fighter) ...
0
votes
2answers
54 views

Object shrinks at same rate no matter what

I am using the following code to shrink a sprite: public bool shrinking = false; public float targetScale = 0.1f; public float shrinkSpeed = 0.1f; void Update () { if(shrinking) { ...
0
votes
0answers
28 views

Unity Android character controll with UI Buttons

So I'm trying to find a good tutorial which will explain how to controll character in 2D game when button is clicked (left, right, jump button). All the tutorials I've found are outdated and not ...
0
votes
1answer
29 views

Object automatic create new with old every time when load / save game.?

My problem with this DontDestroyOnLoad(cube.gameObject); When I load my player position its create new object with default and saved position respectively. I have a screen shot for better understand. ...
0
votes
1answer
46 views

Covert Minimap render texture to 3d space position

I am using Render texture to make a Mini Map it is working fine but now I want to go further on side map and want world space position from render texture click point. Is there any way available that ...
0
votes
1answer
39 views

GameObject eulerangle rotation is off

In a game I am creating players can flip their character. So say the player does a front flip, it triggers an animation that plays to flip the car forward. I have the player as a child of another ...
3
votes
0answers
63 views

How to await async operations / coroutines?

I'm looking for a generic / reusable way to wait for coroutines and asynchronous operations to finish in Unity 5, similiar to C#5's await keyword. The simplest way I can think of is something like ...
1
vote
1answer
45 views

If statement works fine until I add a tag check requirement. Why is this?

I'm trying to add a tag check to an if statement but for some reason when I add said tag check it stops working. void Update () { Vector3 fwd = transform.forward; // Equivalent to the ...
1
vote
0answers
71 views

How to make the Steam overlay work with WPF?

I have developed a game using C#+WPF and the game is currently on Steam (private branch until release). However Steam's overlay isn't working with WPF. Sometimes it tries to appear in the popups of ...
0
votes
1answer
33 views

How to refer to a object that has just been hit by a ray cast?

I would like to use RigidbodyConstraints.FreezeRotation;in order to freeze the rotation of an object that is picked up. The problem is I don't know how to refer (or call) the currently selected ...
0
votes
1answer
38 views

Having trouble setting a game object as a child of another. What is wrong here?

So I'm trying to raycast on mouse click if it hits any thing make that object a child of the sender (in this case the parent). Below is my code... public class PhysGun : MonoBehaviour { private ...
0
votes
1answer
26 views

More efficient using invokerepeating or update?

Im fairly new to unity development and I am working on repeating an enemy. I currently have the functionality working correctly in which I use invokerepeating to spam an enemy. Now, I have an if ...
0
votes
1answer
47 views

How to save slider button positon on saved value.?

I am new to game dev. I have below code and it`s work good. I can change volume using this code and with AudioSource slider script. I also saving this volume state using playerprefs from 0-1. My ...
0
votes
0answers
28 views

Animation is slow on iOS Device and fast in Unity editor?

I had made a Settings popup in the game and animated it like scale animation (from 0 to 1) values. It is appearing very smooth and works good in the unity Editor, but after building to the device it ...
0
votes
1answer
34 views

How to get an game object to instantiate lower than where It's created?

When I press the collider where my allies spawn I want for them to spawn a little bit lower when I instantiate. I have tried to use Vector 3 and GetComponent, but It gives this error: ...
-3
votes
1answer
50 views

Why do I have to do minus-equals for the x-coordinate but plus-equals for the y-coordinate?

I found a simple script in C# in Unity5 to make the camera follow the mouse: xRotation -= Input.GetAxis ("Mouse Y") * lookSensitivity; yRotation += Input.GetAxis ("Mouse X") * lookSensitivity; ...
0
votes
0answers
42 views

XNA Access violation from KernelSoundEffectInstance

Some users (but not all) are reporting a periodic crash in my XNA game. They say it's happening every 15 to 20 minutes. I am unable to replicate this myself, so I asked users to send me error logs. ...
1
vote
1answer
80 views

Fade to first level, on click

Good evening all, about to pull my hair out because I cant figure out why I keep getting this error. The problem is this, I need the player to click on the start button, then, the screen will fade to ...
0
votes
1answer
26 views

using Mathf.Clamp in Vector3 to restrict object drag

I'm making a checkers game and I've got a movement controller working to move the pieces. I want to restrict the drag to be within the board. The center of the board is 0,0 so the far left side's x ...
0
votes
1answer
56 views

How to “print” sprites on a 2D canvas (UNITY5 - C#)

I wanna show a minimap on the screen, but I don't have any idea to how to paint something in a panel on a canvas by code. I've tried instantiating a prefab image but didn't get to work. Any ideas? I ...
0
votes
1answer
48 views

Animator.Play() only works the first time

I am creating a game in Unity 3d that is using an animation to move an object. For some reason the animation only works the first time it is accessed and from then on it acts as if it is not being ...
0
votes
1answer
19 views

When accessing components, is it better to do so in a script or to create a reference to them in the inspector?

I am accessing the variable of one script from within another and I noticed there are multiple ways to do this, but two that are very similar. The first is to simply find the game object and ...