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
vote
2answers
26 views

Translating a world position to an array position

Lets keep this simple, so, assuming I have an array like this ... var array = new bool[10,10,10]; .. and then I have a start and end vector3 ... var start = new Vector3(-21,-21,-21); var end = new ...
1
vote
1answer
28 views

What is the maximum value of a LayerMask in Unity?

What is the maximum value of a LayerMask in Unity (the value when all layers are included)? And how can I find it using C# bitwise operations? I tried ~0 but it shows -1 in intellisense. Thanks in ...
0
votes
0answers
36 views

Save and retrieve image from database in unity

I have done a sample to insert and retrieve data from MySQL in unity.Now I need to insert and retrieve image from MYSQL in unity. The images are files selected by the user from their filesystem. Can ...
1
vote
1answer
21 views

Unity RaycastHit2D sprites error C#. Figured out that this code only works on 3D colliders so how do I change it so that I can use it on 2D colliders?

Figured out that this code only works on 3D colliders so how do I change it so that I can use it on 2D colliders? Below is the c# code. using UnityEngine; // This script allows you to drag this ...
0
votes
2answers
141 views

Should clients in an online game access the database directly or through a game server?

first im total noob about c# and mysql. Just trying to find which way is better. i believe your answers prevents me from losing plenty of time. Online game(not more than 50 users at pre-alpha. Not ...
0
votes
1answer
44 views

Rotate a UI Image exactly 360 degrees over the course of 1 second?

I have a UI Image that I want the user to click and have it rotate 360 degrees once on the z axis. I can get it to rotate through a coroutine but I'm having trouble making it stop once it is started. ...
0
votes
1answer
59 views

Zoom at a specific point using Orthographic camera

Currently I can perform Zoom which seems to be working fine but essentially what I'm really trying to do is zoom on a position offset from center as currently when I zoom then zoom is performed at the ...
1
vote
1answer
36 views

Unity3d Transfer of value from one script to another

Script 1 public class enemy : MonoBehaviour { private Vector3 Player; private Vector2 PlayerDirection; public float Xdif; public float Ydif; private float speed; private ...
0
votes
0answers
41 views

Purple screen when using vertex shaders

Alright, so I've tried everything I can think of. I've put in over 10 hours into this crap, but nothing seems to work (tried multiple online tutorials as well). Always purple screen. Here is the ...
-1
votes
1answer
41 views

Making the player Jump in like a Upper - Right manner in Unity

Ok so i'm new to unity and I am trying to make this simple ball game . Now in a situation I want the ball to jump in a diagonal manner (i.e W + D ). Scrip that I have makes the ball jump only Up and ...
1
vote
0answers
89 views

Turning On/Off Vsync no longer working when rendering to an offscreen buffer

I have this reaallly strange issue that as soon as I render to an offscreen framebuffer I am no longer able to toggle VSync while my application is running. I am using OpenTK as the opengl wrapper, ...
0
votes
0answers
25 views

LineRenderer doesn't apply material in 2D Unity5

I'm making something that draw lines with mouse on top of everything (in 2D), but the color of the line is always purple even though I assign a material to the line renderer. I could change the color ...
0
votes
1answer
59 views

Boolean change when clicking the left mouse button (not working)

I want to change a boolean when I click the left mouse button, but it doesn't work as expected. I use this method: if (m.LeftButton == ButtonState.Released && m_Old.LeftButton == ...
0
votes
1answer
21 views

InvalidOperationException when peeking from a stack within custom editor

I've got a simple state machine for handling game states which works using GameObjects that I enable/disable in order to switch the states. Since some states can be loaded additively (such as the ...
0
votes
3answers
63 views

Gameobject not destroyed OnCollisionEnter

I have this GameObject with the tag coin I am trying to destroy when the player collides with it using this code located in a player script attached to the player public void ...
0
votes
0answers
15 views

Making unity inspector accept classes that inherit from a base class

I have a base class that has a lot of classes inheriting from it, I want to make a script that you can drop one of these derived classes into. How do i do that? abstract class thingy : ...
0
votes
1answer
41 views

How to address a function inside an if condition using C# in unity 3D

I am new to game development and have very limited idea of C# syntax. I was watching unity 3D tutorials of UI and thought of using ModalPanel.cs and TestModalWindow.cs In a quiz game where 3 choices ...
3
votes
1answer
73 views

Why is quad rendered at the center (0,0) instead of top left when using orthographic projection

I have been trying to render a quad(containg a texture) using orthographic camera so that the quad can be rendered using the screen coordinates directly. I started of by rendering just a triangle ...
3
votes
0answers
39 views

(Monogame) Camera does not travel the way it is rotated

I've implemented camera control with mouse and keyboard. My problem is that camera goes crazy when I'm using mouse and camera does not travel the way it is rotated. Could you explain me why and how to ...
0
votes
0answers
23 views

(Monogame) Camera does not travel the way it is rotated [duplicate]

I've implemented camera control with mouse and keyboard. My problem is that camera goes crazy when I'm using mouse and camera does not travel the way it is rotated. Could you explain me why and how to ...
0
votes
0answers
31 views

Rendering water with Hardware Instancing xna/MonoGame

I was wondering if rendering in XNA/MonoGame will be better using Hardware Instancing. For example, I have my editor and when I click anywhere on my map, i'll add a plane with a water texture. If I ...
0
votes
0answers
31 views

How i can make a spherical world with Cubiquity in Unity

I would like to make a spherical planet with cubiquity in Unity 5, how could I do it with a for (), so I could one cubic planet. Can anybody help me?
3
votes
2answers
117 views

How can I create an “afterimage” effect like this one?

How can I make an effect like this? With a particle system?
2
votes
0answers
108 views

Struggling with simple orthographic projection for a 2D setup

I'm trying to build a simple setup for 2D using SharpDX. Basically I want to supply my vertices in classic Cartesian coordinates: X-right, Y-up, starting with (0,0) in bottom-left corner. I've had ...
0
votes
1answer
36 views

Unity3d Resources.LoadAll<Sprite> empty array

In my resources folder structure I have myself a file, now in the unity editor this file is a Texture Type Sprite (2D and UI), now when I attempt to run this code in one of my scripts var icons = ...
0
votes
1answer
54 views

How to rotate camera counterclockwise around player?

Holder contains camera and rotates around player Camera looks like in diablo, titan quest, grim dawn, etc I cant rotate camera to negative angle values My code: public void ChangeRotation(float ...
1
vote
1answer
37 views

Implementing getters for a singleton script in unity

Ok the title might be a bit confusing but what I want to do is make a getter that returns the class, exactly like unity does with the camera.current. You should just be able to go class.current and ...
0
votes
1answer
69 views

Why does Input.GetKey(“enter”) never return true?

I want to modify an int variable on one script by having another script subtract 1 from it. But when I try to trigger this on an "enter" key press, nothing happens. 1st script: public class ...
0
votes
1answer
40 views

Why do my obstacles float above the ground? Unity2D

I'm making an infinite runner game and I'm trying to spawn obstacles, but all of them float far above the ground instead of being at the ground level. This is the code on summoning the bears. ...
0
votes
2answers
43 views

How to get obstacles to spawn randomly in x position in an infinite runner? 2D

I'm trying to make two obstacles that are different sized to come in a random order in one straight line where the player is going. Doesn't have to be with object pooling. It seems that the ...
-1
votes
1answer
25 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
50 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 ...
-1
votes
1answer
32 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
51 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
60 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
75 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
101 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
36 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
54 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
20 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
90 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
70 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
44 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
89 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
38 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
48 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
0answers
56 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
31 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
44 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
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 ...