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

How to assign GUIText from heirarchy into prefab object?

I want to assign GUIText from heirarchy into prefab using that C# code: private Text HighScoreText; void Start(){ HighScoreText = GameObject.Find("HighScore").GetComponent(); } But ...
4
votes
1answer
797 views

Custom Editor for Map/Dictionary in Unity

I'm trying to build my own little ResourceManager in Unity that will allow me to tag resources (ranging from materials to prefabs) to a label in the editor, and then access them in game. The ...
9
votes
5answers
3k views

How do bullets work in video games?

I came across this question when I was designing a video game in C#. If we consider games such as battlefield or call of duty, hundreds or even thousands of bullets are flying at the same time. ...
1
vote
1answer
212 views
+100

Calculate the displacement of device in unity

I'm making a 3D game in unity where the object should move forward and backward as the android device moves/accelerates in the Z axes. ie. When the player moves the devise in the direction of the +ve ...
4
votes
3answers
2k views

Why doesn't my C#6 code compile in Unity?

Why can't Unity work with C# 6 code? It always gives me compiler errors. Here are some code examples: using static System.Convert; using static System.Environment; $"€{punten}{NewLine}€{Money}{...
1
vote
2answers
124 views

XNA makes the console flicker

I create a Window XNA game project from the template in Visual studio 2015. Then I right click and set the property to console application because I think it is convinient to use Console.WriteLine() ...
0
votes
1answer
23 views

Unity saving and loading of images in game

So I'm planning out this game for unity but I don't know how feasible it will be with all of the image loading and saving. I've worked with some other coding, and while I am in the process of ...
1
vote
0answers
29 views

UDP client code throwing a very nonspecific exception

so I'm writing a UDP server and client on a couple of the machines in my virtual reality environment to allow (in this case) data from the location in the environment to trigger some air nozzles. The ...
4
votes
1answer
166 views

AI using character controller makes unwanted change to it's y position

The enemy parent object does not have any colliders except for the character controller. It starts out with y = .57 and immediately jumps to y=1.6355 because of my call to CharacterController.Move(.) ...
3
votes
1answer
112 views

Are there spritebatch drawing limitations on monogame?

I've reached a point that it seems when I draw too much on screen, monogame starts doing weird things. When I call this code in the Draw method public void drawDialogBox() { if (...
1
vote
0answers
22 views

How to compare two skeletons by using kinect sensor?

I need to know about how to compare record skeleton with live skeleton in C#. If there are any reference please let me know.
0
votes
2answers
126 views

Detect Input.GetMouseButtonUp outside a GameObject in Unity?

How do I detect Input.GetMouseButtonUp outside a specific GameObject's area in Unity? Are there any Unity Assets for this?
0
votes
1answer
57 views

Sudoku generation doesn't finish

Heyho, i got problems with my sudoku generator. First of all I generate some numbers between 1 and 9 and put them (according to the sudoku rules) into my game. After that I solve it using my second ...
0
votes
2answers
78 views

Need some advice on how to decide where to implement my enemy behaviours

I'm in the middle of writing a platformer game in Unity using C#. I have my character, if he presses the kick button his state switches to kicking. During this "kicking" state the character doesn't ...
0
votes
1answer
34 views

AutoFill function and methods not working in unity 5.3.5

I opened one of c# code in my projects, and edited something in the code, and I noticed that MonoDevelop no longer gives auto filling of function and method options. Below is the screen shot of the ...
1
vote
1answer
62 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 ...
0
votes
1answer
48 views

Access to varibles in other attached gameobject script is ambiguous

I'm trying to create reusable scripts that I can drop on my GameObjects. I am currently trying to figure out how to build a projectile script. Ideally, I want to be able drop this scrip on an enemy, ...
0
votes
1answer
17 views

Unity 5 - Occlusion culling 2D error

I'm trying to set a Occlusion culling on my topdown 2D game. I have made a sprite object with a Occlusion Area on it.Once I try to bake it, it gives me the following error: No Renderers that are ...
1
vote
1answer
52 views

Tire mesh rotates faster than wheelcollider in Unity

I have a car in Unity. Scripts are C#. I have noticed that my tire meshes' rotation is faster than whellcollider rotation. I am using this code for wheel rotation flWheel.localEulerAngles = new ...
0
votes
0answers
19 views

Unity With C# script : Class Data Type Passing Value From Class Data Twice Weird [on hold]

I got a simple Question and weird from passing value to data type class variable. The code below : Constructor : public item (string name, int ID, string desc, int harvestx, int time, int stdpricex,...
2
votes
1answer
345 views

Questions about scaling in a 2d game in unity

Okay, so: I am making an android game. I want everything to scale to the size of the screen I'm using. Further, my static background needs to scale (as well as every other object), but if the aspect ...
1
vote
2answers
54 views

How to slow down this rotation

My goal here is simple. I am making a top down shooter kind of game, and I want the player to simply rotate in one axis, towards where the mouse is on the screen. I got it working, but it rotates so ...
1
vote
1answer
78 views

Unity syntax highlighting with VSCode

I'm using VSCode, not VisualStudio for Unity scripting. VSCode has syntax highlighting for C#, which works fine, but all the Unity related stuff like Vector3 doesn't get any highlights. I know, that ...
1
vote
1answer
28 views

Correctly creating/handling events for keypress in MonoGame C#

I'm having trouble finding the best approach to registering an instantaneous user key-press with MonoGame (where the key has been held down and then released), using events in C#. Unlike the click of ...
0
votes
0answers
20 views

Unity With C# Script : Class Data Type Variable Array Issue Replaced [on hold]

I got a simple question to ask. Just Check below code and the question is in the end at the result of code. I hope you guys can help me.. file inventory.cs using UnityEngine; using System....
-1
votes
2answers
38 views

AddComponent with string in unity5

At runtime I want to copy one Gameobject component to another gameobject. In my case I have one camera where multiple scripts are added with values settings. the same components i want to add into my ...
4
votes
2answers
62 views

Changing some color of a texture using C# in Unity

It's almost 2 days that I'm looking for a way to do this in Unity using C#, but still no luck. Imagine you have a texture with different colours (this texture can be a rug), and you just want to ...
3
votes
1answer
230 views

Problems with Raycasting Requirements

Im working on a script which kinda works like an Enemy AI. Its kinda like a detection system with requirements that are required to be met. This is a recent question i asked using my code Raycast ...
0
votes
0answers
18 views

Scaling window with Monogame.extended issue

I'm trying to scale the game window in Monogame (I also have installed Monogame.Extended). (Example of what I want to achieve) I've been doing this setting manually the PreferredBackBuffer when ...
1
vote
1answer
111 views

Can't call GameCenter in my Unity game for iOS

I'm trying to integrate Game Center into my Unity 5 project and facings troubles. It seems that authentification is OK when the game starts on iOS device, a notification appears, but leaderboard ...
1
vote
1answer
100 views

XNA4\ Monogame 3d Collision detection Help please

i have been trying to get 3d collision working for a while and i think(hope) you people can help me so for my project i have created a 'sprite3d' kinda class which is called ModelEntity and there ...
1
vote
1answer
44 views

How to follow a car with correct rotation

I am making a game where car will follow a user car. I am moving use car using keyboard keys it is working fine running on my game environment roads smoothly. To follow enemy car i am using nevMesh, ...
2
votes
1answer
432 views

Image target display in unity Vuforia

I am using unity 4.5.1f3 and using the Vuforia sdk 5.0.5.I have downloaded the sample project from the Vuforia site.When I tried to run the sample of Imagetarget project,it asked to add license key....
0
votes
1answer
73 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 ...
-1
votes
0answers
21 views

How do you understand Unity3d Scripting errors? [on hold]

So there are these things in Unity called "Compiler Errors" which is a message you get if you have an error on a JS or C# script, it would also "Give you an explanation" to what's wrong with it, I ...
1
vote
1answer
94 views

Calculating unique ID number from a set of bitmasked tiles

So I write this kind of match3-style game where you as a player need to match tiles with three or more of the same type and I'm thinking what is the best method to recognize the shapes without writing ...
3
votes
1answer
40 views

Respawn not working properly upon scene reload. Why is this?

So I made a respawn function and what is supposed to happen is the script it supposed to load a saved checkpoint. However I need to reset the scene (and again this worked just fine last night which ...
1
vote
1answer
93 views

Uncontrollable platform spawning

I made simple spawner like this: void Update() { if (PlatformPosition.spawnNewPlatform) { NewPlatform(); } } public void NewPlatform() { if (active) { newTransform = ...
3
votes
2answers
1k views

Unity2D: Automatic scaling of camera and sprites

I'm working on a point-and-click adventure game using Unity2D for mobile devices and possible PCs and I'm trying to wrap my head around supporting devices with different screen sizes and aspect ratios....
1
vote
4answers
52 views

How to find nearest gameobject on one side

Here is an example: The left enemy robot is closer than the right enemy robot, but I want the character to attack the robot that is closest to him on his right side. I can't use Physic.SphereCast ...
1
vote
1answer
44 views

MonoGame creates a copy of song files in XNBs location

I'm having a problem. I've been adding .wma files to the Content Pipeline app to be used as my game's background music. But today when I opened the solution/project/content/bin/music folder I spotted ...
3
votes
2answers
614 views

Preventing a Combination of Rigidbody Jump Force & Bounce Magnitude in Unity3D

I'm building a fairly simple marble racing game in Unity3D. The ball is a 3D physics object that moves only on the X and Y axes. It has the ability to roll left and right, and to jump. Pretty basic ...
1
vote
2answers
164 views

Determine facing direction mecanim 2d movement

I'm using this script to move my character in my 2d world: public float speed; //Movementspeed public Rigidbody2D rbody; Animator anim; void Start () { rbody = GetComponentInChildren<...
0
votes
1answer
48 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.
1
vote
1answer
45 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 door....
0
votes
3answers
281 views

How to access multiple 2DTexture which is assigned in Unity3D inspector panel created by an array in C#?

I am making a puzzle game, i made 5X5 cube, lets take example of orange. very left column is orange, upper with orange dot is static and lower with orange dot is also static. inbetween there are 3 ...
1
vote
1answer
34 views

Should I slow down my animation with co-routines or update the animation state?

I want to gradually stop the car animation as it collides with another car gradually speed up the car animation as it exits the collider I have two ways to achieve this. Update Co-routine For ...
0
votes
0answers
29 views

Unity C# - The object of type 'Object' has been destroyed but you are still trying to access it

I have a cube on a plane and I'm tring to move it to certain locations. I've baked the area and added a navmeshagent to the cube. My moving script for the cube looks like this: using UnityEngine; ...
3
votes
1answer
240 views

Local avoidance together with any-angle types of A* Pathfinding

Recently I have been implementing the Block A* any-angle path-finding algorithm in a project I have, for which I need extremely efficient results due to the large number of NPCs. However, I still do ...
1
vote
1answer
79 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 ...