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

-1
votes
1answer
31 views

Unity List spawner problem ? C#

I have four spawners in my scene that spawns four enemies. My problem is when I try to add game objects to the list it works but only for one spawner. My code if (Score.levelNum >=2 ){ ...
0
votes
0answers
60 views

Networking issue in Unity - listening port is already in use

I am trying to Network a small 2 player Unity game. This is my first go at networking, so please feel free to correct me on anything I am doing wrong. I am attempting to make a simple matchmaking ...
0
votes
1answer
40 views

Error CS1061: doesn't contain a definition for `transfrom' and no extension method `transfrom' of type `PlayerControl' could be found [closed]

I tried finding a solution, but I couldn't find one. I'm getting the error: GameManager.cs(15,46): error CS1061: Type PlayerControl' does not contain a definition fortransfrom' and no extension ...
0
votes
1answer
54 views

Trying to make a 2D Spring

Still a Beginner at Unity 5 and this time I am trying to make a Spring. The spring would act as you'd expect. Something comes in with a direction and force, so you bounce it the opposite direction of ...
0
votes
2answers
61 views

Stamina Bar refuses to go back up

I am creating a very simple script for my stamina bar to go down when I press M, but when I am not pressing M, for the bar to go back up slowly back to 100.The bar goes down fine when I press M, ...
0
votes
2answers
91 views

XNA/MonoGame creating a player

After some fine-tuning on my game's GUI I am finally ready to begin with the gameplay. But that's a tall order. My game will be something like a 2D platformer with RPG elements like collecting armor, ...
-5
votes
4answers
132 views

How to access a variable from another script in Unity c#

I need to access a variable from another script in Unity, but I can't figure it out. Script: public class move : MonoBehaviour { public float speed; // Use this for initialization void Start () { } ...
0
votes
1answer
39 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 ...
1
vote
1answer
60 views

Playing multiple sounds in Unity5

I have multiple AudioClips that I have attached to a GameObject and I'm trying to play them when certain conditions are met. Each clip is in an array and I have each array item attached to a ...
0
votes
1answer
22 views

Audio not playing until after button release when it should be playing while it's pressed

I am trying to play the sound of a car accelerating while a user has a certain button pressed, however, the audio clip isn't playing until after that button is released. Can anyone explain to me ...
0
votes
1answer
104 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
1answer
92 views

Accessing a database with a php script from Unity mobile game

So I am attempting to keep track of some user data in my game that I am creating in Unity 3d. I am using Unity's WWW class to do this. I am following this tutorial: ...
2
votes
1answer
81 views

Having trouble creating multiple sprites from one class

So I am trying to make more than one sprite using a single class but I cannot seem to get the sprites to be drawn at all or drawn in different places (they are all just on top of one another). In my ...
3
votes
2answers
94 views

How do I find the location of a GameObject in C#

I'm making an elevator script. Essentially I'm wanting to find the difference between two empty objects so that I can move the elevator between them. To be able to do this, I need to be able to get ...
0
votes
0answers
45 views

Multiplayer rigidbody not receiving velocity syncvar on the client

I have a scene in which on a certain event the client spawns a prefab with the variables of position, rotation and rigidbody velocity set for it. It is working perfectly, it spawns in the right ...
0
votes
2answers
50 views

Using Variable to Reference Different C# Script

I had a question about using a variable to access different scripts. I have a Rhythm game I'm working on, and I have different scripts named Rudement1, Rudement2, Rudement3, ect... One of my other ...
3
votes
1answer
89 views

How to do an anti sway bar for a car in Unity 5?

I have researched some examples of anti roll bars for Unity but they are all for unity 4 and bellow so they do not work in unity 5. Can someone please assist me in making an anti roll bar script in C# ...
1
vote
1answer
39 views

How do I toggle color writes in SlimDX 11/Direct3D 11 with FeatureLevel 10?

I'm having trouble setting the RenderTargetWriteMask field of a RenderTargetDescription struct. I simply want to toggle color writes but every time I try to enable the the color writes are changed ...
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 ...
0
votes
1answer
101 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
42 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
180 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
33 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
111 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
44 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
28 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
71 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
104 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
139 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
29 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
80 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
88 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
125 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
44 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
101 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
110 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
67 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
85 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
114 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
109 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
21 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
228 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
30 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
74 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
148 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 ...