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

Shrinking an object at a given rate

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) { ...
-1
votes
0answers
15 views

How to read from .json [on hold]

I have data in .json file.I am looking for ways to parse it in c#. My json contains data like this, {"howManyToSpawn":1,"positions":[1],"difficulty":0} ...
0
votes
1answer
15 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
25 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
19 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
30 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 ...
-1
votes
0answers
31 views

Fade out / fade in scene w/ loading screen [on hold]

I've got a (very simple?) requirement I just can't get to work, even though it's been covered by numerous tutorials and how-to's on the web. Basically, I want to transition between individual scenes ...
-2
votes
1answer
48 views

HOw to add dontdistroyoload(); to sctipt?

I am new to game development. I have a script with audio source and one slider to adjust volume of audio. I want to keep my this music for all scene. so i must have to use DontDestroyOnLoad(this);. ...
3
votes
0answers
31 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
40 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
42 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
35 views

Given a rotated transform, get normalized (proper up, front) version

I am working on a game where you roll a wheel down the track. Now I am looking to implement a feature, where you could turn it left and right, but I cannot get the proper vectors through which to ...
-1
votes
0answers
41 views

How to make UI tower placement in 2D tower defense like kingdom rush using Unity? [on hold]

I want to make a 2d tower defense where the player can choose one from any towers , i have try to watching tutorial on youtube, read e-book and surfing the internet, but i can't found how i can make ...
0
votes
1answer
25 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
35 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
22 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
40 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
21 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
30 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
47 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
35 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
40 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
22 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
45 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
38 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
18 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 ...
0
votes
1answer
40 views

Recognizing runes drawn by user

I want to implement a system where the player can draw runes on the screen with multiple gestures. Meaning its not just one motion it can be up to 3. So far I have implemented the $P Recognizer . In ...
0
votes
3answers
53 views

Make object follow another object while keeping the same distance from it

I want an object to follow another object just like the way it follows it when it's parented to it, but smoothly and only in the x and z axis. Here's my code so far: distanceX = player.position.x - ...
1
vote
2answers
25 views

How to make a Sprite be displayed always behind everything else?

What I am in need to achieve is to have a Sprite always facing the camera identically to what happens with any simple game UI object, but instead of always displayed above everything else, it should ...
0
votes
0answers
9 views

HOw to load all “ *.extension ” file from specific folder in unity.?

I want to load my all file from folder of "* .dat" or ".txt files in list one by one. And If you can help then also tell me to make them all clickable with different event respectively.
0
votes
0answers
28 views

Defining camera/view space

Im working on expanding my camera class, but having trouble defining camera/view space in the manner of this diagram: What Im trying to achieve is to define the camera as a true object much like a ...
-2
votes
1answer
14 views

Unity3D: Entering a trigger disables a few bools for no reason

I'm trying to make it so when an object enters a collider with the tag "Down" a single boolean turns false, but the problem is that more than one booleans(canGoUp, canGoLeft, canGoRight) are turning ...
0
votes
2answers
40 views

Quaternion not giving correct value back. What am I doing wrong here?

Right so I made a quaternion and assigned it a value but it reports back the wrong value. Here is the relevant code... Quaternion LeftTurnLimit = Quaternion.identity; float test = 0.1f; ...
0
votes
0answers
16 views

MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it [closed]

I am trying to carry over the player over to the next scene. I am having a problem. The player is going over to the scene to soon and I notice this message displays at the bottom ...
0
votes
2answers
45 views

Why can I not change a Sprite directly? [closed]

I am changing the Sprites on an array of Images. I could think of two ways to go about it. The first way being: var images = GetComponentsInChildren<Image>(); foreach(var image in images) { ...
0
votes
2answers
44 views

Collider Effeciency Question

I'm creating a game where hundreds of rockets with colliders attached are shooting at a player. Should I write my script where: 1: The player script reads the collision from hundreds of rocket ...
-1
votes
0answers
40 views

How do i properly develop a multiplayer solution for my game [closed]

I am developing a 2d Role playing game in XNA C# I want to make the game multiplayer (so people can see one another and "attack" the same monsters") so i programmed a server for the game where people ...
-3
votes
2answers
72 views

what is perfect manner to load scene and than player position.? unity 5.3

Here i have problem with scene and object position. My problem is position of object/player changed after load scene. I don`t know why this happens?. I have saved my object position with ...
0
votes
0answers
53 views

Unity UI Drag and Drop with conditionals

I have a nice UI drag and drop system (big thanks to quill18 and BoredMormon for their tutorials) and want to get some conditionals in it. I have 4 numbers (that are instantiated on the canvas) that I ...
0
votes
0answers
26 views

Unexpected Execution Order in Unity (uNet)

I made a little game in Unity. It works fine in the Editor. But if I run the build version I get a NullReferenceException. This problem does only appear if the build-version-client hosts the game. ...
-1
votes
2answers
72 views

Most Efficient Way to Store player stats/data in Unity C#?

I am looking at storing player data in Unity from a script that I'm writing in C# and I would like to get an opinion on the best way to store the player's stats/data about the player like hours ...
0
votes
3answers
54 views

Unity method to get a vector, which is x seconds behind another moving vector (A bit like TrailRenderer)

I want a function, which lets me follow a vector with a bit offset or delay, like it's done in the TrailRenderer. I tried to achieve this with the Lerp function, but that didn't work for me like I ...
1
vote
1answer
36 views

How to make a temporary collision?

I have a key and door system working, the character(ball) picks up the key and when it is within the collider it sets the text("press E to open") on the screen to active so that they can open the ...
0
votes
1answer
24 views

Unity move canvas slightly with smartphone acceleration

I'm developing an AR-App with the Samsung-GearVR. To get a smooth UI, I thought about creating a UI, which is not completely fix, I thought it could be nice, when the UI is slightly behind my head ...
4
votes
1answer
66 views

Can I use xna tutorials to learn monogame?

Can I use xna tutorials to learn monogame? I can't find any good monogame tutorials but there are tons of xna tutorials available and from what I have seen they are pretty much the same thing.
0
votes
0answers
33 views

Using the perlin noise of unity efficiently?

I have a little problem with my perlin noise values. It is generating a voxel mesh, that is flat. Here is a picture that demonstrates what I mean: As you can see, the terrain lacks any ...
0
votes
0answers
19 views

Clip on model XNA

I'm currently doing my water plane system (with waves etc...). Actually, I have a heightmap with a waterplane on it; refraction and reflection working perfectly, but now I want to add objects. So ...
0
votes
0answers
45 views

Side-Collision for Breakout game where ball moves fast

So I've been trying to make a breakout clone, which is my first attempt at a graphical game, I ran into some problems, and was hoping that this community could help me. I've got most of the mechanics ...
0
votes
1answer
64 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 ...
0
votes
0answers
47 views

Making ships shoot bullets

I'm programming this in C# with Windows Forms and I want to know how to make my ship go from the top to the most it could go the left then go down one row and go to the right and so on until it ...