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

How can I set up a delay before the rotation happens?

How can I set up a delay before the rotation happens? I tried StartCoroutine, yield WaitForSeconds .. But I failed.
2
votes
1answer
36 views

Getting the Volume of an Uneven Mesh

Let's say I have a cube, and that cube breaks apart into 100 different unevenly sized pieces. How can I get the volume of each of those pieces compared to the cube's volume? Using this in order to ...
2
votes
1answer
621 views

Creating a Static function inside my class to handle small housekeeping tasks

I have used Unity 3D for quite some time, and a lot of my game programming experience originates from using UnityEngine. Writing in XNA, I am setting up a nested list of objects. Each object will be ...
1
vote
1answer
41 views

How to Slice the external Spritesheet programmatically by using C# in Unity

I have a sprite sheet like this: I am using Unity Engine to develope my game. I would like to load this external spritesheet outside and slice it as Grid type programmatically instead of using ...
-2
votes
1answer
48 views

How can I make a gameObject “stick” to another gameObject after it has collided with it?

How can I make a gameObject "stick" to another gameObject after it has collided with it? Right now the gameObject just passes through! [C#]
0
votes
2answers
45 views

Unity - Determine direction vector3 from a point in space and an angle in eulers

I have a ball positioned as Vector3(x, x, x). I was able to get the direction of the ball to the mouse clicked position with: Code (csharp): Vector3 direction = Direction (clickPos2 - startPos); ...
0
votes
1answer
18 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() { ...
0
votes
0answers
14 views

Use Lerp Position and Slerp Rotation together

This is what I try to do, When I click on a UI Element, the camera smoothly rotate (to look at the target) and simultaneously move on top of the target. To perform that I use a two Coroutine one for ...
0
votes
0answers
21 views

XNA4\ Monogame 3d Collision detection Help please

i have been trying to get 3d collision working for a while and i think(hope) you people can help me so for my project i have created a 'sprite3d' kinda class which is called ModelEntity and there ...
0
votes
1answer
22 views

How to make a in-game timer start with mouse movement in c#? [on hold]

This is my first time learning C#, I need to finish this for an upcoming school project. I have a basic "catch the cookies" game where cookies fall from the sky and the player catches them. I want to ...
1
vote
1answer
19 views

SDL.NET no longer detecting modifier keys

I'm using SDL.NET with C#. Recently, a bug has appeared where the library does not detect if the shift key is held down; although it used to do so. private static void KeyboardEventHandler(object ...
0
votes
0answers
36 views

XNA - Efficient way to get pixel color from rendertarget2D

I'm stuck with a framerate perf down with getData from a rendertarget, what's your idea, what are the other options I can use ? I explain my problem : I'm making a board game, the objects or monsters ...
0
votes
1answer
70 views

How to create 2D shadows and lightning?

How do I create shadows and lights in a 2D top down perspective game? I want to achieve an effect similar to this game (also made in unity) where some objects like a torch, different sprites and the ...
1
vote
2answers
47 views

How to display a list of 2D arrays in the inspector

Simply put, how do I make public List<bool[,]> appear in the inspector? Every 'bool[,]' is a solution to a puzzle in my game and I want to be able to view and edit them in the inspector.
0
votes
1answer
32 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 = ...
0
votes
1answer
34 views

Unity5 How to create a floor

This may be a may be a very basic question but I have a 32x32 tile of grass for a 2D platformer I'm making. Is there an easy way to duplicate the tiles and lay them out? or will I have to copy and ...
1
vote
1answer
76 views

How to avoid lots of ugly math code and constants-hoarding?

In a lot of the games I've (tried) making in the past, I often run into the problem of the code getting really heavy on ugly mathematical code. This happens especially frequently in setting up ...
0
votes
1answer
28 views

Changing long float to number + short scale

I am looking to use a piece of code to take an extremely long number and convert it to decimal equivalent + short scale. (i.e. 120100000000 would be 120.1 Billion) I am doing this with two separate ...
0
votes
1answer
22 views

Delete EdgeCollider issue

In this program, When i draw a hill, a car can road on it's surface, and when I draw another one, the previous hill should remove. but unfortunately the previous edge collider looks still there. ...
1
vote
2answers
66 views

How can I make a gameObject jump quick at first then start slowing down after a while?

How can I make a gameObject jump quick at first then start slowing down after a while? It definitely has something to do with deltaTime.
-2
votes
0answers
27 views

Can someone translate the comments in this script to proper code? [closed]

Can someone translate the comments in this script to proper code? I want to detect a long press on a touch screen then activate an animation. When the finger is released, play another animation ...
0
votes
1answer
26 views

Unity tiles with wierd border flickering when moving horizontal 2D

I recently made some Tiles using a program called Pyxel Edit to create some placeholder graphics. The problem I'm having is that when I move the camera horizontal the edge of the tiles starts to ...
0
votes
1answer
30 views

How can I detect a long press then activate an animation?

How can I detect a long press on a touch screen then activate an animation? And when the finger is released, play another animation smoothly? Let's take for example the main character in Crossy Road: ...
1
vote
2answers
35 views

Create a 2D trail in Unity?

I would like to make a trail for a pixelated snake such as this one : As you can see, the cross simply repeats itself to create the snake. In Unity I have messed around with Trail Renderer, tried ...
1
vote
1answer
50 views

How do you know when you are ready for game programming? [closed]

I've been programming for a while now and I want to make games or game engines. But I don't really know how much of programming one does need to learn to have the proper knowledge to make games. My ...
0
votes
0answers
15 views

Is there a reason to create custom input for character controller in unity? [closed]

Is there a reason why I shouldn't use the cross platform inputs which comes with Unity( the ones in assets->import package Cross platform input). Some people told me that I shouldn't use them and ...
0
votes
1answer
20 views

(Unity) Drag and detect object below when dropping

I'm studying game development in Unity and I want to create a idle/clicker game like Cow Evolution. I'm using OnMouseDown, OnMouseDrag and OnMouseUp to move the GameObject around the scene. Now I ...
1
vote
1answer
50 views

Restricting body movement withing a specific length while dragging a gameobject in unity

private void OnMouseDrag() { Vector3 screen_sp=new Vector3(Input.mousePosition.x,Input.mousePosition.y,screen_space.z); Vector3 cur_pos=Camera.main.ScreenToWorldPoint(screen_sp)+offset; ...
2
votes
0answers
37 views

Monogame Startup Memory Spike

I am currently porting a game from WP7 using XNA to WP8.1 using MonoGame. I have been putting considerable effort into optimizing my game to be under the 185MB memory limit for low-memory phones. I ...
1
vote
2answers
30 views

Proper way to handle Movement/Animation/AI functions of an AI character in Unity3D

My team is currently building a 2D game in Unity and we've run into some workflow/script organization blockades for many of our game's characters. For example, we're not sure what the standard method ...
2
votes
0answers
51 views

Volumetric grass

I've been extremely interested in volumetric technology. Especially in volumetric grass. The online resources are extremely scarce on this topic. What is the difference from creating a lot of ...
1
vote
2answers
29 views

On key press, spawn a collider where my player is facing?

I'm trying to create an attack mechanic to my player hero in my 2D Tower Defense game. When I press the Q button I want my hero to do an animation and spawn a temporary collider shaped as a cone at ...
0
votes
1answer
31 views

Can't see instantiated UI element

I'm trying to create a level editor for a 2D game and I wanted to instantiate radio buttons, the backgrounds and numbers of which are determined by the tilesheet I load. I'm sure I'm doing something ...
0
votes
2answers
54 views

Generate static 2D Tilemap from array

How do I generate a 2D tile map from an array like in this tutorial for XNA ? I basicly want to generate a static map based on my tile prefabs.
-2
votes
1answer
65 views

Unity5 I lost my codes inside .cs file. C# files still exist, but codes gone

Unity 5.1.2f1 (64-bit) version.(windows 8.1) I closed Unity. After a while ago I opened Unity and I had some errors in Console.Then I clicked the error and I realized that I lost my code in some of my ...
1
vote
0answers
119 views

How should we begin to create our 2D Tower Defense? [closed]

Me and my friend are going to make a 2D Tower Defence game as our last assignment in highschool that has to be finished april/june next year. We both know a handy bit of Java and C# but our game is ...
0
votes
1answer
30 views

Collision in EdgeCollider Unity

I want to make a collider for a line that I've drawn on the screen using mouse. so the detection should be cover the whole line that has drawn. What I've learned from edge collider is you can have ...
4
votes
3answers
490 views

Unity 5 disabling a script

I'm using Unity 5 and want to disable a script called Unit based on whether the instance is a client or a server. I have tried using: GetComponent("Unit").enabled = false; However I get hit with ...
0
votes
1answer
24 views

GUI.DrawTexture problem in Unity

I'm having a problem with GUI.DrawTexture() and I'm looking an alternative function to draw 2D Texture Images. The problem I have is that my textures draw above all other objects and when my camera ...
-2
votes
1answer
47 views

I cannot move a gameObject in my scene

I am trying to move a cube to the right in my scene with this piece of code, but it does not work. What is the problem? using UnityEngine; using System.Collections; public class Jump : MonoBehaviour ...
0
votes
2answers
105 views

How to design programatically a game map like Risk?

I'm making a quiz-game based on map territories with a system similar to the Risk game (except there are no tanks but tickets). The map isn't the world but a custom map that I designed and I'll ...
0
votes
1answer
53 views

Monogame/XNA Making animations play once per click

I'm currently making a #gbjam entry and everything has been going smoothly up to this point. My issue being that I've implemented a shooting mechanic and along with it an animation to play as a shot ...
4
votes
2answers
143 views

Best way to handle cornering in a 2D maze game?

I want to implement smooth cornering in a grid, much like Pacman moving in his maze. A big difference with Pacman, my characters can stop- thus the player has to keep pressing the controls to keep ...
1
vote
0answers
16 views

How do i change the vertical fit of a constant size fitter?

How do i change the vertical fit of a constant size fitter? For example changing vertical fit from min size to unconstrained. Is it posible to do this?
1
vote
1answer
19 views

Unity 5.x - Editor only constructor/initilization event

I have three scripts: Level - Represents a Tile Based level. LevelEditor - Custom Editor for Level. Tile - A non monobehaviour class for storing tile information. Level contains an array of Tiles ...
1
vote
1answer
21 views

Strange anomalies when using WinForms with XNA

I haven't seen any questions related to my issue, and this leads me to believe I'm missing something minor, however; The Problem I'm creating a game that is effectively launched from a windows form. ...
2
votes
1answer
49 views

How to move on iTween path when a button is clicked

I have set the iTween path and also I have added a button. When I click on the button the object should start moving along the iTween path.But issue I'm facing is when I run my project at initial ...
1
vote
4answers
58 views

Moving Object on One Axis

Hi Im trying to move some 3D text on one axis, but for some reason it moves on 2 with this code. Can someone explain why this is/ how to fix it? Maybe this is a simple solution but i cant find it. ...
0
votes
1answer
49 views

Background Scrolling like Zelda - A Link To The Past with XNA [duplicate]

i am trying to create a background that scrolls like the one in zelda - a link to the past. in other words: i have a bigger "screen" than the camera covers, so i need to scroll over it, when moving. ...
0
votes
1answer
18 views

Having trouble with a trigger zone. How do I make it so that it deletes certain objects, but ignores others?

I'm trying to setup a system where I pickup an object drop it into a zone, and then the object is destroyed. So far I have: using UnityEngine; using System.Collections; using UnityEngine.UI; ...