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

2
votes
1answer
222 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
2answers
103 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
25 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 ...
-3
votes
2answers
96 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
1answer
46 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
1answer
47 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
82 views

Uncontrollable platform spawning

I made simple spawner like this: void Update() { if (PlatformPosition.spawnNewPlatform) { NewPlatform(); } } public void NewPlatform() { if (active) { newTransform = ...
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: ...
2
votes
3answers
708 views

Player jitter when positioned at large coordinate values

I am trying to make a simple top down scrolling shooter using Unity3D comprising of the following elements: 1) Top down orthographic camera: points at 65 degrees towards the ground. At a height of ...
-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; ...
2
votes
2answers
172 views

2D Collision at corners using C# - without xna or unity

I'm trying to make collision for a 2D game, the player (car) has to collide with the walls of the track when it hits them. I looked into pixel color detection, and X,Y -based collision (But since its ...
0
votes
3answers
75 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 - ...
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 ...
1
vote
1answer
72 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 ...
1
vote
2answers
64 views

Unity Teleport Script issue

I wrote this script quickly just for moving across my map for testing purposes. I created a prefab with this script on it and gave it the Destination GameObject which works fine, it teleports me as ...
0
votes
3answers
3k views

What are the steps to instantiate a button in Unity?

Given a Canvas test_canvas containing a Button test_button and an empty GameObject that manages instantiation and scripts and the like called test_manager, what are the steps to instantiate this ...
-1
votes
1answer
60 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 ...
3
votes
2answers
559 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 ...
3
votes
2answers
2k views

Scale a game object to Bounds

I'm trying to scale a lot of dynamically created game objects in Unity3D to the bounds of a sphere collider, based on the size of their current mesh. Each object has a different scale and mesh size. ...
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 ...
0
votes
1answer
45 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 ...
1
vote
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 ...
1
vote
2answers
33 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 ...
3
votes
1answer
208 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 ...
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.
1
vote
1answer
417 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 ...
0
votes
0answers
32 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 ...
0
votes
2answers
42 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; ...
1
vote
2answers
153 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 = ...
-2
votes
1answer
15 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
52 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
46 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 ...
0
votes
3answers
60 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 ...
0
votes
0answers
21 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
2answers
198 views

How to do moving Rorschach using Perlin noise in c# without shaders?

I want to be able to make a moving Rorschach using Perlin noise like in this question but I know nothing about shaders. Is there a way to do it in just c#?
0
votes
0answers
75 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 ...
1
vote
2answers
737 views

Can't set up a PS3 controller in Unity

So I connected a ps3 controller to my computer via USB cable, when I press play I am able to move by using arrows on the left of the ps3 controller and also I am able to shoot and aim by triangle and ...
0
votes
0answers
38 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. ...
0
votes
0answers
52 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 ...
-1
votes
2answers
96 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 ...
4
votes
1answer
103 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
36 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 ...
1
vote
3answers
318 views

How to restart the game when pressed enter in XNA

If the following code allows the game to exit when pressed esc .. if (gamePad.Buttons.Back == ButtonState.Pressed || keyboard.IsKeyDown(Keys.Escape)) { this.Exit(); } Then this code should ...
0
votes
0answers
55 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
103 views

How can I destroy a game object across the network in Unity?

How do I go about destroying a game object across the whole network in a multiplayer scene in Unity? I can only get it to destroy on the local client and not for everybody else connected. I'm ...
0
votes
2answers
104 views

Flipping car animation with coroutine not functioning properly

I am creating a game in unity 3d that has to do with cars. If you double jump and you are holding the joystick in a certain direction then the car will flip that direction (360 degree flip). I am ...
0
votes
1answer
47 views

Physics Object on Client moving too quickly in comparison to the Server: Should be a copy

I have a client server scenario. On the Server a force is applied to a 2d object. I want the client to copy the movements of the server but not through constant positional updates. My current approach ...
-1
votes
2answers
51 views

How to pass the snake to pass through one side of the screen and come out the opposite side in c# game?? Help me :(

How do I code the left and right collision, and also tell me how I can set the collision of snake according to the form size. If i want to change or maximize the form, snake should collide with the ...
0
votes
1answer
2k views

Loading different navmeshes at runtime in Unity 5

In order to improve the extend ability of our maps, we load different components of the map at run time. The idea is a user can use Unity to make a map, drop it into a folder and it will be loaded. ...