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
1answer
59 views

Respawn not working properly upon scene reload. Why is this?

So I made a respawn function and what is supposed to happen is the script it supposed to load a saved checkpoint. However I need to reset the scene (and again this worked just fine last night which ...
1
vote
1answer
94 views

Uncontrollable platform spawning

I made simple spawner like this: void Update() { if (PlatformPosition.spawnNewPlatform) { NewPlatform(); } } public void NewPlatform() { if (active) { newTransform = ...
3
votes
2answers
1k views

Unity2D: Automatic scaling of camera and sprites

I'm working on a point-and-click adventure game using Unity2D for mobile devices and possible PCs and I'm trying to wrap my head around supporting devices with different screen sizes and aspect ratios....
1
vote
4answers
66 views

How to find nearest gameobject on one side

Here is an example: The left enemy robot is closer than the right enemy robot, but I want the character to attack the robot that is closest to him on his right side. I can't use Physic.SphereCast ...
1
vote
1answer
46 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 ...
3
votes
2answers
647 views

Preventing a Combination of Rigidbody Jump Force & Bounce Magnitude in Unity3D

I'm building a fairly simple marble racing game in Unity3D. The ball is a 3D physics object that moves only on the X and Y axes. It has the ability to roll left and right, and to jump. Pretty basic ...
1
vote
2answers
171 views

Determine facing direction mecanim 2d movement

I'm using this script to move my character in my 2d world: public float speed; //Movementspeed public Rigidbody2D rbody; Animator anim; void Start () { rbody = GetComponentInChildren<...
0
votes
1answer
49 views

Make a person walk faster when standing on plane/panel in Unity?

Is it possible to make a person walk faster when standing on plane/panel in Unity without writing a lot of code? If so how? I am using the standard asset first person movement prefab.
1
vote
1answer
45 views

How to make a temporary collision?

I have a key and door system working, the character(ball) picks up the key and when it is within the collider it sets the text("press E to open") on the screen to active so that they can open the door....
0
votes
3answers
286 views

How to access multiple 2DTexture which is assigned in Unity3D inspector panel created by an array in C#?

I am making a puzzle game, i made 5X5 cube, lets take example of orange. very left column is orange, upper with orange dot is static and lower with orange dot is also static. inbetween there are 3 ...
1
vote
1answer
39 views

Should I slow down my animation with co-routines or update the animation state?

I want to gradually stop the car animation as it collides with another car gradually speed up the car animation as it exits the collider I have two ways to achieve this. Update Co-routine For ...
0
votes
0answers
41 views

Unity C# - The object of type 'Object' has been destroyed but you are still trying to access it

I have a cube on a plane and I'm tring to move it to certain locations. I've baked the area and added a navmeshagent to the cube. My moving script for the cube looks like this: using UnityEngine; ...
3
votes
1answer
250 views

Local avoidance together with any-angle types of A* Pathfinding

Recently I have been implementing the Block A* any-angle path-finding algorithm in a project I have, for which I need extremely efficient results due to the large number of NPCs. However, I still do ...
1
vote
1answer
80 views

Recognizing runes drawn by user

I want to implement a system where the player can draw runes on the screen with multiple gestures. Meaning its not just one motion it can be up to 3. So far I have implemented the $P Recognizer . In ...
0
votes
1answer
108 views

How do I sync the gameobjects to server in C# unity?

I have been working on Game that consists of 10 Game Objects that have to be sync by the server values. The server decides that which game object will win and then sends command to my side(Client side)...
8
votes
1answer
288 views

Entity component system - game progression

I'm quite new to game development (but not to programming) and I'm trying to figure out what would be the best way to handle inter-world communication. What I mean is this: I've been reading about ...
1
vote
1answer
45 views

Can't access properties of a class

Sorry for the bad title, but I couldn't think of a way to word my problem for a title. So I have this script, with two classes: using UnityEngine; using System.Collections; public class GameItem { ...
0
votes
2answers
37 views

How to use prefab only when in inventory game object?

I created an empty game object named "inventory", whenever I click on an object it transfers into that game object : and I got this far with the script: //Transforms public Transform Knife; //will ...
1
vote
1answer
189 views

Store Player Stats

My character creation order is: Select Race, Select Class, Assign Bonus Stat Points, Customize and Name the character. Because I am using Unity's UI components I am using scripts attached to empty ...
0
votes
1answer
61 views

Is drawing an entire game to a render target and then scaling it up a viable solution to a pixel-mismatching problem?

To clear up some possible confusion caused by my title, my game is meant to be pixelly. I currently achieve this by multiplying sprite sizes and locations by a constant called World.Scale (currently 8)...
0
votes
1answer
607 views

What does EventSystem.currentSelectedGameObject consider the current object to be?

I've been working with UI in my project as of late and I can't figure out what Unity's event system is supposed to return for currentSelectedGameObject. if (EventSystem.current....
3
votes
1answer
82 views

Dragging text element into Text variable unity 4.6

So I was trying to make a UI element to keep score in a unity (4.6) project and I'm having trouble assigning the 'Text' element to the Text variable. So I have the text element with the script ...
0
votes
2answers
94 views

How do I make a game over screen like Temple Run or Subway Surfer?

When you die in one of these 2 games I took screenshots of (Temple Run and Subway Surfers), what exactly comes up to say "Game Over" and posts your score and all-time high score? Is it a different ...
2
votes
1answer
269 views

Handling touch input with Event Trigger

I wrote a simple script to control my 'Player' object: using UnityEngine; using System.Collections; public class PlayerMovement : MonoBehaviour { public float jumpVelocity = 10; ...
0
votes
0answers
47 views

How to make Level Editor in C# for a DirectX engine in C++ [duplicate]

I have been trying for months to make a Level Editor for my C++ DirectX Engine. I have tried using a C++/CLI wrapper or P/Invoke to do this. Neither seems to work. Can someone let me see a sample of ...
1
vote
0answers
28 views

Unable to control trigger events for car animation collsion control

I have different car animation running on the road which have imported from max. I want to make such an intelligent System that if car start to trigger from another car it become stop. So far I have ...
1
vote
2answers
82 views

Using my pathfinding more efficiently

I'm making a roguelike in C# with the Roguesharp libraries, in which the map can be as large as 200x200 cells. When I have an entity requiring pathfinding, I am using Roguesharp's built in pathfinding ...
1
vote
1answer
72 views

How can library classes access SpriteBatch?

I have a spritebatch in my primary game component in a game project: public class GameRoot : Game { private SpriteBatch mySriteBatch; public SpriteBatch MySpriteBatch { get { return ...
1
vote
0answers
126 views

In game replay system doesn't work correctly when animations are used on a character

I have created an in game replay system that essentially just stores each object's position and rotation at each FixedUpdate(). Once an even is triggered, the replay is then played back using ...
3
votes
1answer
405 views

Generating mesh along path

I'm currently trying to generate a path along an array of points(Vector3) This is the result i'm currently getting The dark gray points are the given path The red points are the generated verticies ...
3
votes
2answers
187 views

Traffic system in isometric game

I would like to create a traffic system in my tile-based isometric game and I would like to ask for some good approaches because I don't have a clue how to begin. Right now I have a tilemap and keep ...
1
vote
0answers
54 views

Export UnityProject inside Android Studio's existing project

I am new to the Unity3D, but I have made a small Unity project with a humanoid gameobject. I can move this humanoid with the demo data but I want to move it with the quaternion data which I am already ...
1
vote
1answer
30 views

How to Ignore Raycast for Boxcollider2D by layer or boolean?

how can I ignore Raycasting for specific object,perhaps you say use Queries Hit Trigger but when I use it Ignore all Raycasting for triggers but I want filter Ignore Raycasting for some objects I need ...
3
votes
1answer
155 views

Trying to implement forward rendering in OpenGL

I'm working on implementing forward rendering in my 2D engine, as far as I'm aware everything should be set up correctly, I've ran into some issues earlier but I'm sure I've fixed those at this point. ...
1
vote
1answer
86 views

Problem disposing content from a screen's content manager

I have a problem with my game. I am using multiple classes for different screens, for exemple: Main Menu is one screen, When playing is another, and so on... I decided to use multiple ...
-1
votes
2answers
112 views

how to create a play button and load game on play? Monogame

I need help with understanding how I can make my function work and load the game when pressing play. At the moment, when I press Play, it won't update or missing update o knowing the button is ...
2
votes
2answers
80 views

object smooth orbital limit around another object depending on mouse drag

I am working in Unity. I have special objects that can each be dragged freely around in 2d. The objects cannot get too close to other objects (minimal Vector3.distance allowed is 1.5f). I also have ...
1
vote
1answer
127 views

Unity Collision Doesn't Work when Two Players Instantiated

I am using Unity3D and I have a problem. I have a script which instantiates the player gameobject once you are connected to the server. I also have an attack script. When there is only 1 player on, ...
1
vote
1answer
232 views

How do I render my DirectX C++ engine to a C# Panel?

The title pretty much sums it up. I'd like to know how I can get the HWND of my C# Panel object to my DirectX engine so I can render to it. I know it involves making a C++/CLI wrapper, but I'm not ...
-3
votes
2answers
85 views

How do I write to a text file in Update function of a script? [Unity|C#]

I have a Unity C# Script which updates a variable each time the Update function is called. I would like to know how to write to a file from the update function.
-4
votes
2answers
75 views

How can I test which of two gameobjects is closest to a third gameobject?

It would be nice if it was as simple as: public void Closest() { if (A.distance > B.distance) {} } But any sort of workaround would be acceptable.
0
votes
1answer
104 views

2d Player animation issue in UNITY 3D

I have a player and i want to move the player from left to right. I can move the player by the keyboard events.but the problem is that when i release the key the player animation should be idle. ...
2
votes
1answer
298 views

Modularization in a project

I'm writing a C# game in Mono, and I want the game to be as modular as possible. I've started by writing the whole Item (inventory) System of the game in a seperate .dll library But I've hit a problem....
0
votes
2answers
78 views

How do I reference one gameObject with script attached to other?

this is all in Unity 3D with C#. Thing is, I have attached a script to my player that should Destroy TreeGroup (as in forest) whenever I press 'Q' and Instantiate them when I press 'E'. Here is the ...
0
votes
1answer
33 views

Coroutine wrong Behavior when scene is loaded.

Ok so I have this coroutine : IEnumerator ShowCharTraits() { while(!hasPlayerChosen) { yield return null; traitPanel.SetActive(true); } ...
1
vote
0answers
27 views

Weapon Sway Script messes up weapon rotation

So I'm in the process of learning Unity 5 and scripting in it. One thing I wanted to give a try was to make a simple weapon sway script like you see in games such as battlefield or csgo. After a bit ...
1
vote
1answer
51 views

How to switch between sprites in Unity

So I made an empty game object in inspector, called it "squareTest", and I clicked and dragged 3 sprites in. One is the square being black, one is the square being red, and one is the square being ...
1
vote
1answer
58 views

How to use NoSQL REST API of Gamesparks in my Unity project? [closed]

Gamesparks has a documentation of the API but I am not sure how to send https requests to use that API.
0
votes
1answer
375 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 ...
1
vote
3answers
110 views

Unity AddForce causing twitch

Since this wasn't clear enough, I've removed even more code. It kind of defeats the purpose I was aiming for, but I guess getting any answer relevant to the problem is better than none. What I want: ...