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

3
votes
2answers
66 views

Stopping 3D object in place

I am at 1.2 stage (moving the player) at Unity course "Roll-a-ball" and have question: I want to add feature that stops a player and sets his new position on 0, 0, 0. I can reset the position, but I ...
0
votes
0answers
54 views

Water reflection xna

I'm actually trying to do the reflection map for my water component, but even following the riemer's tutorial about reflection map the formulas provided doens't work. ...
1
vote
1answer
44 views

How do I call the sprite auto-slicer from a script in the Unity editor

First of all let me start with an apology. I know this may not be the right place for this question, but the good people over at stackoverflow did not answer me and neither did I get a answer over at ...
2
votes
1answer
34 views

How do I include XML files in an Android build?

I have a few XML files I want to include in a build of my game, and I want to have access to those XML files in Android. How to I store and load those XML files?
0
votes
0answers
33 views

How to compress an asset bundle and decompress it on iPad or iPhone

In have a prefab size of 2.4 mb, when I convert this into Unity Asset Bundle, the Asset Bundle is goes to 127.2 mb. How can I compress this into small size? My code is: public class ExportScene : ...
1
vote
3answers
57 views

Static variable not holding its value

I am creating a real time multiplayer game in Unity 3d. When a game ends I set a static boolean value called "waitingToEndGame" to true. In Update() it waits a few seconds before moving to a new scene ...
1
vote
2answers
39 views

Unity get more than 2 lines of log height

Unity does only display 2 lines in height for each log, at least with the default settings. I couldn't find a menu, where I could change this. I want to display a matrix, and I need to see the log ...
0
votes
1answer
40 views

Unity C#: Change speed when all Targets are destroyed

I have a game where a Gunner moves on a pre-set path towards a final destination. You play as a Magic Bullet that auto-fires from the Gunner's current position and can be controlled with WASD. When ...
0
votes
0answers
55 views

Unity websocketsharp is closing the connection directly

I got a working code, which I want to change a bit for better readability but afterwards my web socket is just closing instantly. First off, I got this code working : using UnityEngine; using ...
3
votes
1answer
80 views

How do I get data from a WWW object without freezing my game?

I am using Unity 3d to create a real time multiplayer game. I have a database set up that keeps track of player statistics and what in app purchases they have purchased. I have written a Database ...
1
vote
1answer
69 views

Unity2D Isometric layering

I'm developing an Isometric Game but I have problem apply the right layer for make, for example, a wall behind or in front of the Player depending on the Player position. I'm able of getting works in ...
1
vote
0answers
30 views

How to draw SharpDX 2D Bitmap Outline

i want drawing bitmap outline Now Drawing Device.DrawBitmap(mBitmap, GetBound(), Opacity, d2.BitmapInterpolationMode.Linear); // mBitmap as SharpDX.Direct2D1.Bitmap // GetBound() as Bitmap Bound ...
0
votes
0answers
17 views

How can I make an expandable menu and assign names to buttons randomly from an external file using Unity?

I'd like to create a menu on the lower left side of the screen which will present some options (guns) to the player. The number of options should change based on how well a player is doing. In other ...
0
votes
0answers
74 views

How to convert a mouse's “On screen” position to “World” position C# Monogame

So the problem is this... I have a top down game, where you click on the screen to select which unit you want to control. You left click to select, and right click somewhere else to tell it where to ...
1
vote
0answers
44 views

How can I change the list of enum options displayed in the inspector?

I have an array of enums: using UnityEngine; public class EnumsInInspector : MonoBehaviour { [SerializeField] public EnumType[] myEnums = new EnumType[3]; public enum EnumType { ...
0
votes
1answer
55 views

Unity3D - How to get highest value for acceleration from Input.gyro

I'm trying to develop an app that can detect car acceleration, braking and cornering speed. I need to detect device acceleration. Is that acceleration high or low?. Like flo app on Google Play. I'm ...
0
votes
1answer
78 views

Simple 2.5D flight movement

I'm building a simple 2.5D Dogfighting game, kinda similar like this one: https://gfycat.com/PleasantDeterminedArcherfish for the moment my movement works like this: if (Input.GetKey("left")) ...
0
votes
0answers
39 views

Unity2D wall jumping not working correctly?

i've been working on this project for the past week using unity engine, its a 2d platformer similiar to super meat boy.I've been able to program jump sustain(jump higher when you press space longer), ...
0
votes
0answers
20 views

Trigonometric movement cause problem when holding player inside bounds

In my game I have a Player class. Here is what it looks like. public void Update(GameTime gameTime) { // Controls kb = Keyboard.GetState(); if (kb.IsKeyDown(Keys.W)) ...
0
votes
0answers
28 views

How to get vectices of a sprite in correct order in Unity?

Currently, when I examine sprite.vertices, I see that it is ordered in crossed way, like: one from bottom, one from up, another one from somewhere else... etc. I need the correct order to make array ...
0
votes
1answer
21 views

Replace text in Unity [closed]

i tried to look up my question but didn't really find an answer that works for my situation. I'm using this unity asset called Dialoguer to create interactive dialogues. What I'm trying to do is to ...
1
vote
2answers
28 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
31 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
63 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
30 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
156 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
53 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
74 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
40 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
43 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
42 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
92 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
32 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
66 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
26 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
74 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
16 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
45 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
84 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
52 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
38 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
38 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?
4
votes
2answers
140 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
121 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
49 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 = ...
1
vote
1answer
65 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
79 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
43 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. ...