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

Unity C#: Game Object Movement Issue

I'm trying to move a game object within a set x and y range. I thought the code below would work, but it does nothing. The idea is the player controls the platform and tries to move under the ball. ...
3
votes
1answer
39 views

Unity camera tilt

I'm programming a camera for an RTS and I'm stuck on tilting the camera up and down. I want the camera to tilt between 20 and 70 degrees using the Z and X keys. This is my code: using UnityEngine; ...
1
vote
1answer
52 views

Monogame scale/resizing texture without stretching the borders

I would like to scale or resize my texture2d but when I do it, the texture border becomes stretched. Here's an example : This is my original texture And this the texture after I change the Scale: ...
1
vote
2answers
129 views

Can I make this physics simulation any faster?

I've made a little real time physics simulation that solves some bodies. CirclevCircle && CirclevOrientedRect I would like someone to tell me if I'm doing something drastically wrong. I know ...
1
vote
1answer
28 views

How to change the Value in HSV color via scripting [Unity]?

I have a glowing object(point light attached to a ball with a default shader with the emission property) in my scene and I've added a script to make the point light flicker. The script randomly ...
1
vote
1answer
25 views

Can't call GameCenter in my Unity game for iOS

I'm trying to integrate Game Center into my Unity 5 project and facings troubles. It seems that authentification is OK when the game starts on iOS device, a notification appears, but leaderboard ...
0
votes
1answer
71 views

When using Unity 5, is there a way to print/save/identify the last n lines of code that were executed at a specific point?

So, here is what I am after. Is there a way to identify which were the last n lines of code that were executed in Unity 5 (with C#) at a given point of the game? I know I can use Debug.Break() to set ...
3
votes
1answer
73 views

How to propagate component updates? (Changing components at runtime)

Whenever an entity is being added to an entity controller (which is essentially just a bag of entities), I scan through it's components to figure out if I need to register additional entity processors ...
0
votes
2answers
82 views

Is it possible to trigger a loop with key input

Ok I need to know if it is possible to trigger a gameloop with a key press? ex code if (GamePad.GetState(PlayerIndex.One).Buttons.X == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Up)) ...
1
vote
2answers
91 views

How are methods like Awake, Start, and Update called in Unity?

I'm developing with Unity 5 and I know that there are some methods you can use like in the code below: public class MyGameElement : MonoBehaviour { private void Awake() { } private void ...
1
vote
1answer
22 views

FileNotFoundException while using ShaderbyteCode.CompilefromFile method

I'm currently learning SlimDX, I want to load a Shader from tutorial which is named "triangle.fx" and it is in a folder called "FX",everything is in my solution. When I'm typing this line of code: ...
1
vote
2answers
89 views

How to rotate camera using mouse?

I'm looking for a basic example of rotating camera using the mouse. the only problem is I'm not sure of how to rotating the camera around it target. should i do this by an algorithm or is there a ...
1
vote
2answers
49 views

Continous repeatable object/image moving horizontally unity3d

I want to move objects on the screen horizontally. And the user has to pop the object by touching it. When user touch it, it gets destroyed and new object comes randomly. For experimenting, I used ...
0
votes
2answers
52 views

XNA's GameTime.ElapsedGameTime.TotalSeconds isn't working as expected

As I've seen at quite a few website, the best way to handle variable frame rate and movement (moving projectiles, monsters, swinging swords)... looks something like this: //This position += ...
1
vote
1answer
68 views

How do I make 2 players from one Class?

I am teaching myself XNA and only started a few days ago. I am making a clone of Pong and have made a class for the Paddle: I am wondering how I can create 2 paddles one for each player from the ...
0
votes
0answers
17 views

Animation bugging out and returning to idle state whilst moving - Unity 5

So my problem is this, my character, when moving side to side is fine and all animations play out fine. But when moving up and down he glitches back to his idle state. I have it set so that when ...
1
vote
2answers
50 views

example for creating button programmatically

Can someone give me an example of programmatically (not using a prefab) creating a button in Unity 5 using C# that has the following features? a text on the button (that I can change) an ...
1
vote
2answers
50 views

transform.Translate only for 10 units?

How can I transform.Translate (Vector3.up * Time.deltaTime * 2); a GameObject for 10 units? I mean only make it go up 10 units (10 y units).
0
votes
0answers
17 views

change button text using reference to gameobject

I have a GameObject that stores a Button prefab. How can I tell the instance of the GameObject to change its text? My code below fails on the commented line below with the error: ...
1
vote
2answers
31 views

how can I access to new function via getcomponent?

using UnityEngine; using System.Collections; using AssemblyCSharp.portal.www.com; public class Game5_Player: MonoBehaviour { //string Logo; void Start () { ...
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; ...
1
vote
1answer
42 views

Send Messages in Update Function Button UI Unity 5

I've been working on a project where i need to fulfill the following behaviors: 1) when clicking anywhere in the screen the character should do something 2) there are some buttons so except when you ...
0
votes
1answer
23 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
0answers
37 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
38 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 ...
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
66 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 ...
0
votes
1answer
44 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 ...
0
votes
1answer
67 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
46 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
25 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 ...
0
votes
2answers
83 views

Best way to draw 2D shapes on a 3D flat object

I want to draw shapes (arcs, circles, lines) on a table, which is in 3D space. The table top is at Y=0 level and oriented so it points to (0, 1, 0). There are some other 3D objects on the table, so ...
1
vote
0answers
52 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 ...
3
votes
1answer
46 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 ...
0
votes
0answers
44 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 ...
1
vote
1answer
86 views

How to share Unity High Scores on social media (Facebook , Google+ and Twitter)?

This may be a common question but as a n00b I have some confusion on achieving this . I am on a small game project and I want the user to share his / her scores on social media after completing the ...
0
votes
1answer
47 views

Calculating unique ID number from a set of bitmasked tiles

So I write this kind of match3-style game where you as a player need to match tiles with three or more of the same type and I'm thinking what is the best method to recognize the shapes without writing ...
1
vote
0answers
29 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, ...
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
1answer
64 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 ...
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" ...
1
vote
1answer
47 views

“Saving…” dialog isn't shown until after the saving is complete

I have implemented serialization/de-serialization process in my Unity game where I save/load data from/to XML file. During the serialization, my game isn't responding until the serialization is ...
1
vote
0answers
87 views

Procedural Islands Voronoi Pattern

I'm trying to keep this as simple as possible, as I've found out the last few days this is a very difficult topic. I'd like to generate multiple flat islands, formed by a voronoi diagram. I've ...
-1
votes
2answers
56 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() { ...
1
vote
1answer
35 views

Flexible projectile system?

Projectiles need to accommodate timed, homing, linear, and arced behaviours and have single, cone, and splash effects on hit. What is a good pattern to accommodate these different behaviours that ...