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

0
votes
0answers
15 views

storing/retrieving values in dynamically created button script

When I click the button why is the logged text not minion 999 (which is the values I passed in bc.Setup())? When I click the button it outputs the default text of test 6 main.cs using UnityEngine; ...
0
votes
1answer
22 views

assigning script to dynamically created button

I have a script main.cs which creates a prefabricated button based on this SO post. I thought btnController.cs was providing the methods for the Button created in main.cs? Why would it have a casting ...
1
vote
1answer
67 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
vote
2answers
251 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
0answers
31 views

Unexpected behaviour after adding animator and Unity editor crash

I have realy strange problem which accured after adding animator(I suppose) to prefab Object. Situations looks like follow: I had object which have only sprite renderer, collider2D and script ...
0
votes
1answer
37 views

closing GUI in Unity

How do I close the GUI after the user enters a value? Is there any way to stop execution of the entire app (from inside this script) until a value is entered? using UnityEngine; using ...
1
vote
1answer
63 views

Unity 5 - Time Remaining displaying in scene but not in Game

I'm currently learning game development in Unity from this course on Lynda.com. Currently I'm trying to displaying the time remaining in the game after it has been set to 5 minutes initially. When I ...
3
votes
2answers
309 views

calculating torque from angular momentum considering inertia moment

so I am trying to determine exactly how much torque to apply to a 3d model to make it rotate at a particular rate. I apply force from the location of each engine on the craft so if one breaks the ...
0
votes
0answers
24 views

Trying to do skeletal visualization in bind pose similar to blender with octahedral mode

I already achieved drawing octahedral by just porting blender code to c#+opentk. Here ported code: static float[][] bone_octahedral_verts =new float[6][] { new []{ 0.0f, 0.0f, 0.0f}, new []{ ...
1
vote
1answer
131 views

Black Rectangle instead of texture

I am trying to draw a textured ractangle like in this example. But instead of a texture the rectangle is just black. Draw method: protected override void Draw(GameTime gameTime) { ...
0
votes
1answer
40 views

How do I remove specfic OptionData from Dropdown?

How would I remove one of the elements from the dropdown? For example, how would I remove Sprites? Here is my code: public Dropdown researchFeatureDropDown; researchFeatureDropDown.options.Add(new ...
2
votes
2answers
639 views

Why doesn't my C#6 code compile in Unity?

Why can't Unity work with C# 6 code? It always gives me compiler errors. Here are some code examples: using static System.Convert; using static System.Environment; ...
0
votes
1answer
59 views

Transform components in ECS

Many game engines I've seen which are based on an Entity Component System. It has some kind of a Transform Component as a necessary component attached to all of their entities. While this does seem to ...
0
votes
2answers
3k views

Basic C# Script in Unity3D for firing a bullet (not working)

working on a 2D top-down view game. Im trying to get my player to fire a bullet when spacebar is pressed. I added a component to my player (a bullet sprite) and placed it under his gun (so you can't ...
2
votes
1answer
157 views

Supported Orientation, Monogame, Windows Phone 8

I am developing a game in which I need to rotate the screen on Landscape mode or Portrait, and lock it that way. In Monogame, targeting Windows Phone 8.1 adding this code: ...
0
votes
3answers
246 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 ...
21
votes
2answers
11k views

What is the standard C# / Windows Forms game loop?

When writing a game in C# that uses plain-old Windows Forms and some graphics API wrapper like SlimDX or OpenTK, how should the main game loop be structured? A canonical Windows Forms application has ...
0
votes
1answer
293 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: ...
0
votes
2answers
40 views

Unable to hide / destroy AdMob Ads in Unity

I am currently working on a small game project and I want to monetize my game with AdMob ads. So I watched this YouTube Tutorial. It works fine, but the problem is ad appears in all the scenes. So I ...
0
votes
1answer
22 views

Change button sprites in scrollview Unity3D_5.2

I have a scroll view with lots of buttons on it. when i press one button, that button needs to change the sprite and stay like that. if any other button (or same one) is pressed previous button needs ...
3
votes
1answer
45 views

How to add user created data to drop down menu options

So I'm trying to make it that I can have a dropdown that will have user created info appear in it. List<engines> engineList = new List<engines>(); public Dropdown engineSelect; public ...
1
vote
0answers
51 views

Problem in power up generation

I am trying to instantiate an obstacles, Currency and Power up in the game. i am using same script to instantiate all. obstacles and currency are working perfectly but power ups is not generating in a ...
1
vote
0answers
27 views

Help for structuring classes [closed]

I am creating a platformer game with some card base fighting. I was thinking about how should I structure my classes? There are 2 types of cards i.e. Continuous effect and 1 time effect. Also, they ...
2
votes
1answer
190 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; ...
7
votes
2answers
207 views

2D A* Path-Finding

I have this problem, which isn't really a problem, but I feel like it's some sort of glitch in my code maybe. My pathfinder, to find a path from A to B, does this: which is almost fine, it works ...
0
votes
1answer
77 views

Kinematic equations script fail

I added the kinematic equations to my code and now none of it works. I get the error rigidbody.torque assign attempt for 'Enemy' is not valid. Input torque is { 0.000000, NaN, 0.000000 }. ...
0
votes
0answers
43 views

Getting a part of terrain from a bigger one

So I have a terain of size 8192*8192. And I want to get a part of it as its own terrain. I have created a function that gets height needed for terrain, but it just minimizes the whole terrain. The ...
-1
votes
1answer
35 views

Detect clusters of tokens on an x y grid

Ok, so I have a two dimensional grid working on integer x and y coordinates. Each of this coordinates can have one and only one token on it. The tokens have the capability of check and return an ...
0
votes
1answer
37 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 ...
0
votes
2answers
26 views

Using variables in other scripts [duplicate]

I need to use a variable from the main script of a game which is the score variable public int scoreCount; I need it in the main script because it will be needed to update the score when they get past ...
1
vote
1answer
47 views

computationally Intensive routine, ThreadPool or new Thread?

I had to write a computationally expensive routine that runs in 20-30ms. This routine cannot run in the main thread since it would kill the frame rate. The routine runs on demand, when some data ...
3
votes
3answers
2k views

Sprite Animation in XAML/C# for Windows 8 Modern UI (Metro)

I'm working on a project that requires doing sprite based animation in XAML / C# for a windows store app. I've worked out a method for displaying the animation, but it causes flickering during the ...
1
vote
1answer
1k views

Simple heart container script for 2D game (Unity)?

I'm attempting to create a simple mobile game (C#) that involves a simple three-heart life system. After searching for hours online, many of the solutions use OnGUI (which is apparently horrible for ...
2
votes
4answers
109 views

Wall-Sliding, Stuck at Corners

I am having trouble with my 2-D wall-sliding. Namely, when the player avatar collides with the wall, it "snaps" to the corner (see screenshot, below) and sticks there. The red, transparent rectangle ...
0
votes
1answer
224 views

How can I add banking and rotation to this object manipulation script?

I have made a drone script that allows user to move in four directions and ascend/descend. I found a nice tilt snippet which makes the thing bank when it moves. However, when I include this, the ...
1
vote
1answer
163 views

Standard Assets Cross platform joystick sensitivity

I am using the standard asset joystick that comes with Unity 5, the sensitivity changes depending on the device used, for example on an Samsung S3 it is more sensitive than on a Nexus 7 2013, how can ...
1
vote
1answer
56 views

Relation between game systems and components in a component-based architecture?

Based on a question I previously asked here regarding to decoupling input from other components of an entity I developed a small component architecture on top of XNA to understand how everything works ...
1
vote
1answer
163 views

unity - problem in limiting rotation of object?

I am trying to make a game with unity. In this game, player uses mouse to rotate a container or box around x and z (rotate to left and right and also toward the camera and opposite). I used below ...
0
votes
1answer
1k views

Loading different navmeshes at runtime in Unity 5

In order to improve the extend ability of our maps, we load different components of the map at run time. The idea is a user can use Unity to make a map, drop it into a folder and it will be loaded. ...
0
votes
2answers
94 views

What is the most efficient technique for range detection?

I have a bunch of patrolling enemies that fire projectiles when the player is in projectile range - a specific radius. Which method is the most efficient and elegant? overlapSphere sphereCast ...
0
votes
2answers
101 views

Issue implementing proper collision in XNA Game Studio 4.0

I am building a game in XNA 4.0, where a player moves about a 2 dimensional (vertical perspective) map consisting of blocks. My issue is creating proper collision between the payer and the blocks ...
1
vote
1answer
272 views

Questions about scaling in a 2d game in unity

Okay, so: I am making an android game. I want everything to scale to the size of the screen I'm using. Further, my static background needs to scale (as well as every other object), but if the aspect ...
1
vote
0answers
27 views

“following” Object not Interacting with the game world correctly

So I finally have my object detecting the distance between itself and the player. If within range, the following enemy will chase the player down and touch it. (This will kill the player) However, ...
3
votes
1answer
316 views

How can I mask this CanvasRenderer?

I'm creating a text box that allows for selectable text, based off of Unity's InputField. An issue I am now facing is that the selection highlight does not respond to masks (The parent has a mask, but ...
14
votes
2answers
2k views

RTS game unit structure

I want a way to make a lot of different units without having to program stuff like moveTo and Attack actions more than once The way I see it, there are 2 ways I can do this. A single generic Unit ...
1
vote
2answers
229 views

Delegation in unity C#

I have a game where I have balls bouncing and you shoot them. Since I need a way to end the level when the player shoots all the balls I though I would create a game controller script which will ...
0
votes
1answer
31 views

“Following” Object is acting Strangely?

So I recently designed an enemy that will follow the player when he comes within a certain distance of the object. However, there are times when the player comes in range, only for the "follower" ...
0
votes
1answer
411 views

3d Wall sliding collision

I'm working on collision for walls in my game and the way I currently have it I get stuck walking into a wall. I'm trying to make my character slide on the walls but still collide. My character moves ...
-1
votes
2answers
55 views

Delay in the middle of a script in Unity without calling a separate coroutine [closed]

using UnityEngine; using System.Collections; public class WaitForSecondsExample : MonoBehaviour { void Start() { StartCoroutine(Example()); } IEnumerator Example() { ...
2
votes
1answer
911 views

How do i define array in shader's constant buffer with C#?

I am using SharpDX to render 3D graphics and i cannot get to work constant buffer in my shader since it contains an array. Currently it looks like this: cbuffer cb0 : register(b0) { matrix ...