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

Input.mousePosition gives a NullReferenceException

I'm trying to Add raycast shooting to my player but when I get the Vector2 mouse position it give this error NullReferenceException: Object reference not set to an instance of an object This ...
-1
votes
1answer
46 views

C# Unity3D - How can I use a INT from other classes?

I have 3 Objects Capsule 1, Capsule 2 and Capsule 3. Every Capsule has a script on it for health/damage. It also contains an int for hits and points. Hits should be increased by one for every bullet ...
0
votes
2answers
92 views

After sometime increase the speed of Instantiated object

This may look similar to "increase speed after every N seconds" type question but it's different because objects are being Instantiated and getting destroyed. In my start() method I'm calling a ...
2
votes
1answer
167 views

Stretch the game to fit the game window, in Unity 5

(Desktop) I want to make it so that when the user re-sizes the game window, the game is stretched to fill the window. (Similarly, for Android) I want it to be stretched to fit the screen as well. ...
2
votes
2answers
442 views

How do I save and restore an int value with PlayerPrefs?

I am stuck on how to save the player's amount of money. When I build the game in the exe as soon as I shutdown the game my money value gets lost. I want this money to be saved. I am using the ...
0
votes
2answers
176 views

C# Unity3D FPS apply damage to an enemy (Weapon bullet)

I am kindly new to Unity3d and c# and I don't understand how I could let a bullet deal damage to an other object. I've seen a lot of JS tutorials but no for C#. I've tried to use them, but it wont ...
-2
votes
1answer
36 views

Script to change size of a cube when pressing a button [closed]

I am very new to coding and very bad at it. In my environnement there is a table, and i would like, after pressing a keyboard button, to make a cube appear. Then, by pressing another button, i would ...
0
votes
1answer
76 views

After collision of two objects change the sprite and move in its direction

I've searched a lot for this question but there was no answer that could solve the problem I'm having. I'm new to unity and a very naive developer.I'm making a game in unity using c# and it's like a ...
0
votes
1answer
55 views

Editing a new list of vector3's without changing the original list? (Unity) [closed]

I just got Vectrosity for Unity and need to make a line of all the destinations for an object. Issue is that I need to use a single list of vector3's to create the line (as far as I'm aware). I have ...
0
votes
2answers
146 views

How to stop rotation every 90 degrees?

I was facing another rotation problem yesterday, that i managed to solve by rotating the object like this : transform.Rotate (speed * Time.deltaTime, 0, 0, Space.World); I tried almost every other ...
1
vote
1answer
99 views

Random, Infinite Terrain Generation [closed]

I'm trying to generate random terrain for my game (In Unity3D, C#). All I need is water and grass. No height to it (no mountains or hills.) I'd preferably like to do it by placing individual cubes. On ...
0
votes
2answers
43 views

unity2D Top-Dow Mobile rigibody2D

im using this code for my 2D TopDown mobile player movement.but when i move player With UI Image buttons player keep moving.it didnt stop.and also player starting of move he is very slow. the he ...
0
votes
1answer
105 views

Delegation in unity C#

I have a game where I have balls bouncing and you shoot them. Since I need a way to end the level when the player shoots all the balls I though I would create a game controller script which will ...
0
votes
1answer
392 views

Unity 5 How Do I Set Text of Text Component of Input Field

How do I set the text of the new Input Field's Built In Text UI Object in Unity 5+? myInputFieldText.text = "Text Value I Want"; The code above does not work to set the text inside of a ...
1
vote
1answer
103 views

Tile Map Shader?

I'm trying to write a shader in unity that will take tiles from a sprite sheet and draw them onto a tile map. I'm new to shaders so this might be totally wrong, I think it might just be a math error ...
3
votes
1answer
493 views

How to correctly draw a line in Unity

I'm working on a game which requires me to draw a few lines from a single point that is more formally said Given point A with coordinates x,y I draw n lines where the i-th line has the coordinates ...
1
vote
1answer
162 views

OpenGL: Draw an arrow

I'd like to know how to draw an arrow to represent a vector position, length and direction. The issue is that I can't quite find an easy way to know the location and rotation of the triangle ...
1
vote
1answer
51 views

OpenGL why point's size stay the same while zooming/unzooming

i'm currently working on a game engine for a college's project. While implementing some debug tools I came across a little problem. When i'm drawing point on the ModelView Matrix the point's thickness ...
0
votes
0answers
53 views

How to get the position of a moving object

I need to get the position of the moving game object.But when I run the below code I always get the same position. public Vector3 position_store; void Update() { ...
1
vote
1answer
47 views

How can I refactor an enum so that it is still available in the inspector?

I am trying to use an enum so that it is available in the inspector. This code works: public ArmorTypeEnum ArmorType; public enum ArmorTypeEnum { Light, Medium, Heavy }; How can refactor it into a ...
1
vote
3answers
115 views

Learning To Use C# In Both VisualStudio And Unity's Monodevelop Frameworks

I apologize if this has been asked and answered, but I can't find it. I know the framework is different in MonoDevelop and Visual Studio 2010 Express. For instance, if I want to use Write.Line, I ...
0
votes
1answer
227 views

How to animate objects with bobbing up and down motion in Unity?

I have created a 2D platform game with Unity and C# where I have collectable items that can be picked up by the player. What I want is to give the items more focus by having them bobbing up and down. ...
1
vote
0answers
79 views

How do I Animate a character in Unity3D (Animator)?

first of all, I am new to Programming and Unity, but I want to create a simple game with Unity3D. I am using the StandardAssets (character) where all animations are included, but I dont get how to ...
0
votes
1answer
92 views

Fast mesh collision 3D (C# XNA)

I'm trying to write a simple program where a 3D landscape can be walked about with a basic camera. However, I've found it very difficult to do even simple collisions with my terrain. I'm wondering if ...
0
votes
0answers
72 views

Unity3D Interactive Cloth Basketball Net Falling Apart Though Not Tearable

I have a basketball net mesh attached to an Interactive Cloth with the following attributes: The mesh is not segmented and is not marked as tearable but as soon as the game starts the net falls ...
2
votes
3answers
178 views

MonoGame 3.3 Font loading

Is there any way to have fonts in game without making a separate Content Project and adding a .spritefont file in the new 3.3 Monogame? You can now load other resources directly from the Content ...
1
vote
2answers
164 views

Create a continuous flight path on a Bezier Curve in Unity3d

I am working on a game in which a butterfly is flying along some path. What I am trying to do currently is create a Bezier curve starting from the butterfly's position(previous curves end point) and ...
0
votes
0answers
156 views

roll a ball unity 3d

I am learning Unity3d following book "Game development for iOS with unity" by Jeff W. Murray from 2012. Roll a ball game project. I am stuck here: using UnityEditor; using UnityEditor.UI; ...
1
vote
2answers
59 views

Position problems instantiating lasers at the sides of a space ship

I'm developing a demo of a 3D Space Ship game concept in Unity, just for learning purposes. I have a cube representing my space ship in the scene, and a laser prefab that is instantiated at the 2 ...
0
votes
2answers
46 views

MonoGame Point filtering movement appears Choppy/Jerky

When you move a sprite that is drawn using point filtering with a decimal number, example : 0.1 pixel or 100 * deltaTime (1.6) the movement appear choppy/jerky because it jumps from pixel to pixel. ...
0
votes
1answer
124 views

How to change the speed of the gameobject moving on the itween path

I have set an itween path for an object to move.And I have written the code as iTween.MoveTo(gameObject,iTween.Hash ("path",iTweenPath.GetPath("train"),"time",300)); The above code is working for ...
0
votes
2answers
216 views

How to procedurally generate Mountains that Looks more natural

My Terrain was looking a bit plain so to freshen it up a bit I decided to add mountains to the terrain generation. Unfortunately the Mountains don't look very natural with the surrounding terrain. ...
0
votes
4answers
145 views

Assign each player a unique ID?

For my game's multiplayer matchmaking and back-end, every player is assigned a unique GlobalID and LocalID. The GlobalID is used for keeping track of all players and the LocalID is for keeping track ...
0
votes
1answer
132 views

Unity - Proper use of threads with procedural generation

I have been working on a simple chunk based terrain generation system, with voxel octrees. The overall method works pretty well, but testing this system with large amounts of chunks completely freezes ...
0
votes
1answer
87 views

Spawning moving text make it disappear overtime

I am trying to display a text when I click the letter 'R'. When the text appears, it should slowly slide down on the y axis only, slowly disappear over 4 seconds and get disabled. I am not able to ...
2
votes
0answers
89 views

How to implement a professional fighting game input buffer?

Ok guys, I understand how to make a basic input buffer. Here is my code: public class InputBuffer : MonoBehaviour { public int max_buffer; public enum keys { down, up, left, right, X, Y, ...
0
votes
3answers
77 views

How to move an object to a position?

I'm trying to move an object to the coordinates 48.7, 51.07, 102.8, but it does not move. I did some test to make sure that "OnMouseDown" works, and it does, I think it could not be finding the object ...
0
votes
0answers
13 views

I want to swap textures on button click [duplicate]

public class Textswap : MonoBehaviour { public Texture imageone; public Texture imagetwo; private Texture gametexture ; void Update (){ if(Input.GetMouseButtonDown && gametexture ...
0
votes
2answers
42 views

XNA - debugging

I know how to debug step by step in XNA however when I do that the screen is gray and the console does not give out any output. This is a problem because it greatly limits my ability to find problems. ...
0
votes
1answer
88 views

The camera in a 2D tile based side scroller is moving slower than the player [closed]

In my 2D tile based side scroller, I want a camera that scrolls in the x direction, but not in the y direction. The world is separated into three zones; one on the left and one on the right where the ...
0
votes
1answer
198 views

How to show a popup with text when a game object is selected?

We're building an FPS game where you walk around a 3D environment and walk up to objects, click, and then a GUI message pops up. Basically, I've got a character, walking around in 3D space, and is ...
1
vote
0answers
90 views

How do I implement realistic recovery from weapon recoil?

I want to create an equation determining how fast a gun recovers back to its center after it has fired. I have a weapon system functioning based on constants (recoil amount, bullet spread, etc.) ...
0
votes
3answers
94 views

How to rotate a gameobject to the specific angle

I have tree model that is being rotating .After certain angle it should stop rotating.I have done a sample code.But the tree is not stopping. void Update () { //transform.Rotate ...
0
votes
1answer
73 views

How can I implement triple buffering using Direct3D 9?

I am creating an application using Direct3D 9. I want to implement triple buffering with vsync. I can successfully create a graphics device object with 2 back buffers. How do I know which buffer to ...
0
votes
3answers
68 views

Strategy for keeping a primitive facing the viewport?

Using XNA, c#. I'm writing a stellarium-type of program-- well, trying to :-) -- and I have a 'sun' texture that I'll be pasting onto triangle primitives. I'll also be floating some text above each ...
1
vote
1answer
120 views

Apply shader to only a part of a sprite

I'm trying to make an image blur when a transparent image overlays it, I am wanting it only to blur the section that is being overlayed. So if half of the original image is not being overlapped, that ...
0
votes
0answers
332 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. ...
0
votes
1answer
161 views

Unity5 TextAsset not functioning in WebPlayer

Preface I am working on a 2D Platformer in Unity5 utilizing TileMap techniques. I have a working system to read "Room Tile Data" from JSON files with the Unity TextAsset Class and the Newtonsoft ...
0
votes
1answer
141 views

How can I make player move on array of GameObjects in Unity?

I am making a board game where the players hit a dice and move on an array of GameObjects according to the number they got. So I declared a Gameobject array and added to it all the objects I need. ...
0
votes
0answers
54 views

XNA/C# Shadows look strange in orthographic

I have implemented shadows in to my game engine. They look fine when rendered in projection mode as a projected light, however I get a strange "blocky" look when they are put into orho'. I will be ...