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
0answers
30 views

SignalR Monogame Lag

I'm creating a C# multiplayer game in Monogame using SignalR to update the enemy players positions. This is my proxy.invoke: proxy.Invoke("UpdateEnemy", LocalShip.Position, ...
1
vote
1answer
53 views

Limiting Bounds of Camera

I'm using the following code which I've taken from Unity and edited it a bit, but I seem to misunderstand the right way to actually add bounds to the camera controls and the way to implement the ...
2
votes
1answer
37 views

Find your value between four values in a grid based on distance, Unity

Please note: Originally posted in stack overflow, redirected due to nature of problem. I am making a procedural mesh game. I am trying to calculate the temperature for the player's current chunk by ...
1
vote
0answers
18 views

Background replacement with 3D moving objects using Intel RealSense SDK

I have done background replacement with static image and video using RealSense and c#, but now the requirement is to replace the background with the 3D moving object in still background. Is it ...
-1
votes
1answer
84 views

FB.Init() is not accepting in my c# Script

I am trying to connect fb with my game. its first time i am connecting fb with game. i downloaded fb SDk 7.3.0 and i am using unity 5.2.1f1. i imported the sdk in my game asset. then i created a new ...
2
votes
2answers
697 views

Control animation using animator control class

I did a sample existing code to control animation using animation.I dragged and dropped a character into the scene then I added a Animator to it and added the animator controller.Below I have given ...
3
votes
4answers
227 views

Get OnMouseDown to work with a 2D Polygon Collider

I'm having a hell of time getting a 2D polygon collider to register a mouse click. I've attached images and code to show where I'm at. I cannot get the click to work. Ultimately, the thing I'm trying ...
0
votes
3answers
278 views

Unity Application.LoadLevel freezes the game on Android device

I'm developing a game using Unity. The game has a single level and after the player wins/loses, I simply want to reload the same scene. Here's the code I'm using: private void OnLevelFailed() { ...
4
votes
2answers
267 views

How to impale and stack targets correctly according to the collider and its coordinate?

I'm making another simple game, a catch game, where a spawning target game object must be captured using a skewer to impale it. Here how: At the start, the falling object (in red) will fall in a ...
-5
votes
1answer
56 views

New to game development [closed]

I have some programing experience, and I have tried making some games. I have some knowledge with c#, but I am much better at python. I have a general code structure knowledge, so I am open to learn ...
0
votes
0answers
28 views

Unity AddExplosionForce to a Navmeshagent

the navmesh agent is intaracting with the exploding object, explosion occurs and agent takes damage but no pushback occurs. expodingobject using UnityEngine; using System.Collections; public ...
1
vote
1answer
51 views

Animation Scaling?

I have an animation that changes the scale of the GameObject but also happens to change the position as well. I do not want the position to be changed by the animation, only the scale. How can I do ...
0
votes
1answer
91 views

How to stretch screen image to fit higher res monitors set to lower resolutions with Unity?

Using Screen.SetResolution(width, height, windowMode); , how might I stretch the image to match the monitor size? I've noticed this problem occurs both with this line of code and also the default ...
0
votes
2answers
245 views

animation control problem

I have a list of .FBX object.When I drag that .FBX into scene its corresponding inspector Animation component(fig 1) appears but when I drag some other .FBX object into the scene the Animator ...
0
votes
1answer
38 views

Enemy Retargeting

i am trying to make a game using navmesh agent in unity,where the enemies first attack the player and change their target to tanks when player spawns them.then again retarget player after the tank ...
4
votes
3answers
2k views

Issue with Monogame resizing

I've converted my XNA project into a MonoGame one. Whenever I start the application and resize the game manually (ie - dragging the window)... this.Window.AllowUserResizing = true; ...the game ...
3
votes
2answers
51 views

Problem in if statement comparing GameObject name

I am trying to get the name of the game object. for that i used Debug.Log (gameObject.transform.ToString()); in start. My gameObject name is "PowerupItem_0" and "PowerupItem_1". in console it ...
1
vote
1answer
173 views

Unity provides wrong Input value if game is started with bumpers pressed down

As the title states I am having an issue with the following. It is a pretty specific edge case but it is something I can't work around. In Unity I have created two Axes to allow me to check the value ...
1
vote
1answer
194 views

How Can I Find a Shape on 2D Array?

For the code in my test project, I want to find 2D[,] array shape on the char[][] list. I created an actual map with 'char[][]' array. So, how can I find a tileChar's shape on the worldChar array? ...
0
votes
2answers
74 views

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

I am working on a simple game project, and have a problem. The problem is accessing the variable from one script to another. For example :- I have 2 Scenes (Game Scene and Game Over Scene), Game ...
4
votes
1answer
57 views

save a particular area of the scene as screenshot in unity

I need to save a particular part of the scene as screenshot. I have done a sample to show the particular part of the scene. When I click on the rectangular area the selected area will being shown ...
0
votes
1answer
35 views

My rigid body controller stuck in middle of screen (unity)

Still working on my Star Fox clone and am changing up the camera a bit. The problem I keep having is my Ship gets locked in the middle of the screen and can't move while its parent (spinMe) is still ...
1
vote
1answer
90 views

How can I locate GameObjects near the player in Unity?

I'm trying to figure out how I can find GameObjects that are close to the player so that I can delete them with Destroy(). I know how to use Destroy() but I can't figure out how to get a reference to ...
1
vote
0answers
20 views

Collision destroy a cube when player collides [closed]

Unity- I have a mesh named and tagged as player I want that when it touches a Cube it should get destroyed C# script I need ....ty
1
vote
2answers
63 views

Detecting first or second Mouse Button Release?

I want to know how to detect if the user has released the mouse button the first time, or the times after that: Pseudo-Code: if *first* (Input.GetMouseButtonUp(0)) { do something } ...
4
votes
2answers
113 views

Unity 3D C# - Shifting beetween worlds?

Let's say I want to replicate Planeshifting from Legacy of Kain: Soul Reaver in Unity. There are 2 realms: Spectral realm and Material realm. The Spectral realm is based on the Material realm, only ...
0
votes
1answer
29 views

Hang script on the button in unity [closed]

When you click on a hand should trigger the script. I do not understand how this script to the button. Here's a script, even though he can not correct: using UnityEngine; using System.Collections; ...
0
votes
1answer
72 views

Health Bar is always 100% full

I have this GUI to graphically display a variable similar to the health in a game. The variable 'test' goes up and down during gameplay. To show this I have the following onGUI (): public GUISkin ...
0
votes
0answers
15 views

Buttons duplicated on game scene

I have this set of buttons in a monobehaviour class: public GUISkin btnskin; public Texture2D emptyTex; public Texture2D fullTex; public Vector2 pos = new Vector2(20,40); public Vector2 size = new ...
0
votes
0answers
36 views

Face Detection in Vuforia Unity Android

I am working on face detection in unity.I have tried out a face tracking sample from the below link.It worked fine https://github.com/marcteys/unityFaceTracking The problem is that,when I runned the ...
0
votes
2answers
38 views

Should I use Coroutines to change variables in inspector smoothly?

I want to change the aperture of the depth of field in the camera smoothly by using Mathf.SmoothDamp and a Coroutine, however, since I'm new to game development, I don't know if this is the right way ...
0
votes
0answers
37 views

Unity Player Smooth Left - Right Movement

I am learning Unity 3d . Now I want to move the player object (The Ball) , Left and right by Left Arrow and Right Arrow key . I want smooth movement when the player goes left , but I don't know how to ...
0
votes
2answers
80 views

Monogame resolution problem (without scaling sprites)

So I'm working on a project and started working on a scaling system for different resolutions. I know if you change the monogame resolutions, that the texture won't scale but I noticed deformed ...
0
votes
1answer
59 views

Click event doesn't trigger when clicking

I've made some buttons on my screen to navigate to other scenes of my Unity project but the Click(string command) method doesn't trigger. I've placed a breakpoint on the bold line in code below, but ...
0
votes
0answers
41 views

transform.Find() doesn't find the specified object

I am learning Unity and C# and I've hit a wall trying to use the transform.Find() function. I am following Brackeys' tutorial for 2D platformers (https://youtu.be/m-J5sCRipA0?t=10m53s) and using the ...
13
votes
3answers
2k views

What's the difference between UnityEngine.Random and System.Random?

What is the different between this int randomNumber = UnityEngine.Random.Range(0, 10); and this private System.Random _rnd = new System.Random(); // other code int randomNumber = _rnd.Next(0, ...
1
vote
1answer
37 views

scaling problem with some resolutions

So I made a scaling system for different resolutions, and I got very weird results. I have an old "scaling" system where you can choose which scaleSize you want (for testing with the old 800 x 450 ...
2
votes
1answer
62 views

What's the best way to make multiple objects of the same thing?

I am coding in C#. Due to limitations of the environment I will be working in, I cannot use any framework like the XNA Framework; only what is provided by default on Windows. I want to create ...
0
votes
1answer
43 views

Doesn't Unity5 support Expression Bodied Properties?

I wrote the following line in Unity5 using C#: private static float Width => 0.015f; Unity complained about the following issue: Unexpected symbol `=>' in class, struct, or interface member ...
4
votes
1answer
232 views

How can I make a scrollable text view?

I am trying to do an appication in monogame windows. I have a long text to be displayed on screen. I tried to render it on screen using spriteBatch.Drawstring, was succesful to an extent. But, the ...
1
vote
1answer
48 views

Making a Fall Trigger Game Over

I have been struggling with this fairly basic issue: To make a game over menu appear upon death. I am making a 3D game in Unity, where you, the player, must control a sphere with the basic controls: ...
0
votes
1answer
87 views

Unity Singleton accross multiple scenes

I have a game where my code is designed to be on a single scene so I've implemented a singleton like that: public class MonoSingleton<T> : MonoBehaviour where T : MonoBehaviour { private static ...
0
votes
1answer
704 views

Movement Issues: jumping to another GameObject

My code can make a GameObject jump while simulating gravity. Now I want my GameObject to jump. The purpose of this is to always have a nice "touchdown". Instead of the parabola, I want to use my jump ...
0
votes
2answers
54 views

How to destroy object after animation

I've made an object and when the player has pick it up, rise it up and stop it out of screen. But because you can see the shadow of that object, I will destroy it after the animation has played. But ...
0
votes
1answer
35 views

Automapping of the noise texture onto 3D model

I want to apply kind of noise/dust texture to objects so it would look good, and make it without having UV mapping in models. This is because I want to have a possibility to apply this to any objects, ...
3
votes
3answers
65 views

MonoGame - Ordering Movement Key Presses

I'm looking for a way to retrieve the last key pressed even when other keys might be pressed for a top-down four-directional game. For example: W is pressed → Move up D is pressed → Move ...
0
votes
1answer
36 views

Why does transform.forward appear to be void?

I have the following line of code from a project I'm working on: this.transform.position += (keyMapping.Value * this.movementSpeed).Scale(this.transform.forward); At a first glance, this line of ...
3
votes
2answers
452 views

Most efficient way to convert Vector3 to Vector2

What is the most efficient and fastest way to convert a Vector3 to a Vector2? Casting: Vector2 vector2 = (Vector2)vector3; Initailizing a new Vector2: Vector2 vector2 = new Vector2(vector3.x, ...
2
votes
3answers
116 views

How to implement a job queue system?

Essentially I'm trying to make a system which you can add a job to it then finds an AI which is idle and gives it that job to do, For an example look at Prison Architects job list system (image ...
3
votes
1answer
124 views

new graphicsdevice returning null

I tried to make a collision box visible (for testing) with spriteBatch.Draw(with a blank texture) in my TileSprite class. I needed a GraphicsDevice for this so these are my variables: Texture2D ...