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

How to create a dynamic Map in Unity (Augmented Reality)

I created a dynamic map with a LineRenderer. The LineRenderer gets a new position assigned, for each movement my 'character' does. It works good, but I expect it to get a really bad performance at ...
0
votes
1answer
36 views

How do I lerp text color over time?

On my quest to understand Unity in a zero to hero sort of manner, I've run into a new problem I can't seem to really solve. From computer science I know that updating GUI on the same thread as ...
1
vote
1answer
165 views

How can I delete parts of a mesh in Unity?

I am trying to make a destructible game environment; I want to delete the vertices (and triangles assorted to them) within some sphere of a given radius with its center at the contact point (in ...
0
votes
1answer
31 views

How do I interpret the differences between the “Time” and “Self” columns in Unity's profiler?

I'm not quite understanding how to read the results of the profiler: A method Pathfinding_NodeAdjuster.CheckSpecificArea() method is using up 94.7% of the BehaviorUpdate overall time, while taking ...
1
vote
2answers
109 views

Pausing the game

I've had a look around and kept finding about using Time.TimeScale = 0 to pause the game, although this is the normal way to do it, it is not exactly what im looking for. When my menu button is ...
0
votes
0answers
38 views

Causing a rocket engine to 'cut out' (Scale down and re scale up)

In a game im currently working on I have a fuel bar for the player. What I am currently trying to do is have the fuel bar, at around 25%, cause the player engine to cut out a little to represent the ...
-1
votes
1answer
43 views

Detect the position of the mouse press? [closed]

I am encountering an extremely absurd phenomenon. When I run this code on my smartphone via Unity Remote or even on the computer, it works as expected. But when I install the APK on the device and run ...
0
votes
0answers
23 views

Preventing a NavMesh agent from moving Diagonally?

I'm currently working on a topdown game that uses 3D models. I am planning on using the NavMesh system in Unity to handle the movement of my NPCs, however, the NavMesh agents move diagonally when ...
1
vote
2answers
69 views

Unable to move GameObject?

This simulates a GameObject swinging between two positions. I am unable to manually move a GameObject on the Y axis using the Unity editor (in scene view) when the following script is attached and ...
1
vote
1answer
95 views

Designing a stats system

NOTE: I am currently not using any frameworks or other game dev tools like Unity - this is purely written using c# 6.0 in Visual Studio 2015. I would be interested to learn about any frameworks or ...
2
votes
1answer
116 views

How do I “teleport” an object in Unity?

I'm trying to make a script where once a player triggers a collision they are teleported to another position that is determined by a empty game object. I think it has to do something with the ...
1
vote
0answers
23 views

Translate D3DXMatrixLookAtLH to Unity compatible code

I am currently trying to port a really old Game (I have the source of it) to Unity as a fun project. And I'm currently stuck with the object rotation techniques in Unity compared to the ones used in ...
0
votes
0answers
41 views

My Movement Function is working good but called only once

I have a function, It's working but not getting called every frame if It's in canMoveDown function but !canMoveDown its not. if (!canMoveDown && UpdateTilePhysics(currentBoardPiece)) like ...
0
votes
0answers
27 views

Why does Intel Graphics Monitor crash after I set a depth stencil state in my Direct3D 11 application?

I'm programming a managed Direct3D 11 application with SlimDX. I want to use Intel Graphics Monitor to capture draw calls for a single frame. When I try to set a depth stencil state my application ...
1
vote
1answer
71 views

Loading font in Monogame

This question is probably a duplicate but I'm still asking it since it's all yesterday that I'm trying to get this done without any success. I followed many solutions and tried even more libraries ...
-1
votes
2answers
55 views

How can I implement Player Prefs to Save High scores in unity?

I am new to both unity and C# and facing trouble in saving and displaying the highscore.text in the game.Til now I only successfully managed to display the scoreUI and update them whenever player ...
1
vote
2answers
95 views

Player shooting himself when moving - Unity UNET

Setting : Creating my first multiplayer game and running into an odd issue. it's a tank game where players can shoot bullets and kill each other Problem : When the client shoots while moving, the ...
0
votes
0answers
41 views

How to create a ghost mode to replace Human character 2D platformer

I am making a 2D platformer with a character that requires a player to go through a few obstacles to reach the finish line. I want to make it so that after a few tries and obtaining a set of input ...
1
vote
2answers
91 views

Calculate Position on Tile Map by single Index

I stumble about a Math Problem for calculating a Position on a dynamic tile-map. So i got a List of Tile Entities. Every Tile got his one unique Index Value and i have to set the parameters for Map ...
0
votes
2answers
100 views

How to fix my tile-based game's tile movement code ? (like a CandyCrush Style)

I'm currently creating a tile-based game like a CandyCrush style direction movement (no problem on only down movement) trying to smooth, not laggy tile movement with a board piece, and I'm writing a ...
0
votes
1answer
33 views

Setting a Boolean as a field of an object from another script

I saw this question asked some times but no one correlates to mine. I see people using the GetComponent() function but this one should work too. First I receive a Bool value from a toggle button and ...
0
votes
1answer
65 views

Passing strings padded with white space into a byte[]

I am using Google Play services for a real time multiplayer game in Unity 3d. When sending the data in a byte[] in the multiplayer update I have to pad certain entries going into the byte[] with white ...
0
votes
0answers
58 views

Unity 5.3 Asynchronous Texture Upload in C#

I want to load textures asynchronous in C#. I heard it that it is possible to do it in Unity 5.3. However documentation doesn't mention how to do it in C#. Does anyone have an idea how it works? ...
1
vote
1answer
100 views

Initializing Consumable product to an amount on first use

I am using Unity's In App Purchase plugin to implement an in game store. In my game every player has fuel. I'd like to use the plugin in order to keep track of the amount of fuel the player has so ...
0
votes
0answers
16 views

Move car with script [duplicate]

How would I go about writing a car script in C#. Is there anything special I would need to code. Or is it simply if pressed certain button, Rigidbody.AddForce() or transform.Translate(). My question ...
0
votes
3answers
71 views

Creating a toggle button in unity3d Scene vs Scripting

I am making my first GUI in unity, and I am not sure if should create the toggle buttons in the game scene by creating new UI elements or by scripting. Creating them in the game scene gives me more ...
0
votes
0answers
20 views

Removing the little box from a toggle button

Hello everyone I've this toggle button: public Texture2D togglebutton; hydro.t1Bool = GUI.Toggle (new Rect (25, 155, 100, 50), hydro.t1Bool, togglebutton); everything is fine, in my scene I added ...
0
votes
1answer
131 views

SceneManager.GetActiveScene(); return -1 when Debugging active scene in editor

I'm trying to use the new SceneManagement since Application.LoadLevel is obscelete and I've read that we need to put it like this. using UnityEngine; using System.Collections; using ...
0
votes
1answer
27 views

How to find the participation id corresponding to a sender id

I am creating a real time multiplayer game in unity 3d using Google Play Game Services. In my function where I deal with the positioning of players based on information that is sent from other ...
0
votes
0answers
70 views

Unity3D freezes when running a project with webservices for the second time

This is a strange one and I've been trying and searching for a solution for days now. I have created a simple webservice that queries a local MYSQL database and returns the result for the client. ...
0
votes
3answers
122 views

Move Camera When Player Move C#

i developing side Scrolling endless Game. i want to Change X Axis of camera as player moving to Right. and i almost Done That. but the problem is when move Camera to the Right then its look so stiff ...
0
votes
0answers
28 views

Undesired Rotation Produced by Mouse [duplicate]

I have the following C# script for my gameobject:- mousey = Input.GetAxis ("Mouse Y") * sensitivity * Time.deltaTime; mousex = Input.GetAxis ("Mouse X") * sensitivity * Time.deltaTime; ...
0
votes
1answer
46 views

Access buttons individually made by a for loop (old Unity GUI, Unity Editor script)

I've got a problem and I am struggling with this for a couple of days now. I am making an Editor script and I want to access buttons individually when created by a for loop. There is a public class ...
0
votes
2answers
65 views

Pass Vector2 to Instantiated GameObject

I am trying to get an AI sprite to randomly shoot a SINGLE bullet while walking around. This is a 2D Top-down perspective. The sprite can move up, down, left and right. It randomly changes directions. ...
3
votes
1answer
69 views

Is it Possible to play Musics / Songs stored in the mobile to play inside the game?

hi I am creating a car game, I just like to know is there is any way to play the musics Stored in our phone to play inside a game? If the player select MP3 player the songs stored in the mobile wants ...
0
votes
3answers
70 views

Trying to get two variables to stay in sync between 2 scripts. Anyone know what the issue is?

Basically I am making an inventory system where the player has a set amount of objects, and if they go to a pickup then it will give them more of that particular type of object. I have two problems ...
0
votes
1answer
47 views

Script for non-stop enabling/disabling “Is trigger” on collliders2d in Unity3D?

I had asked before that I have a problem with too many colliders in one spot and that some upgrades of towers I have are buggy due to that. It has come to my notice, that whenever I enable the "Is ...
3
votes
2answers
69 views

How would I create a billboard that is fixed to my camera's farplane?

I'm trying to set a GameObject(plane) to be positioned at my camera's farplane. I plan on using this billboard as a sort of dynamic skybox. How would I create a billboard that is fixed to my camera's ...
0
votes
1answer
80 views

how to start the game without entering into menu screen

i am trying to play the game without entering to menu screen. i have placed only one scene. my ui and game both is placed within the same scene. in my game over screen i have two buttons. for home ...
0
votes
0answers
52 views

Unity: How to create tiled sphere?

I want to build a simple random planet generator and thought of using tiles to generate the surface. I googled for hours, but I couldn't find anything helpful. At least all things I found didn't work ...
0
votes
1answer
62 views

How to have separate UI section in Monogame?

So I have a game, and you can move and attack and move the camera around, etc...but I want to have a section of the screen dedicated to Character info like health, etc. How do I make a fixed section ...
-1
votes
2answers
99 views

Display text one character by one [closed]

In a game over screen I am trying to display the text "GAME OVER" one character by one. public float letterPause = 0.2f; string message; private TextMesh textComp; public void DeathMenu() { ...
0
votes
2answers
39 views

How to make transitions between images in canvas (unity)

So I have 3 same images, but with different colors which I want to cycle in my menu. They are only with different hue/saturations and I want them to slowly reduce their alpha 1 by 1 so that the one ...
1
vote
2answers
82 views

Unity: detect animation's end

I need a way to detect if animation's clip finished playing and then execute a certain code. Here's some script, that I wrote (called in Update): if (Input.GetButtonDown ("Fire1") && ...
0
votes
0answers
14 views

Displaying a timer ontop of a duplicated gameobject? (Unity2D)

So I have a timer which has for example 30 seconds and when it's over it destroys my gameobject. I can make I wonder how can I take this timer and display it ontop of every one of these gameobjects? ...
0
votes
1answer
31 views

Finding x and z value in the direction of another object

In my game you can drive a car and it has an arrow point to an object you need to drive towards. The arrow pops up above the car using the same x and z value as the car but adding 2 to the y value. ...
0
votes
1answer
40 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
64 views

Unity3D: 'Physics' does not contain a definition for 'Raycast'

I'm a complete beginner in Unity 3D, and I'm following a video training. In the video the instructor uses the following code to open a door using raycast: using UnityEngine; using System.Collections; ...
0
votes
3answers
52 views

Unity3D-2D: Setting Time.timeScale to 0 for a certain public prefab until positioned?

So I have a button in my game which spawns a "tower" at a given location. The tower, when spawned, acts normally and I can drag it around using my drag script. I wonder how can I set the ...
0
votes
1answer
40 views

Draw a Texture to fit a rectangle

I would like to draw a texture in a rectangle that is smaller than the texture, normaly the texture will be scaled to fill the rectangle, which results in a squished image. I want to draw it to fit. ...