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

How to disable and enable a randomly generated prefab in an endless runner 3d

Hi all I have been experimenting the endless runner game for some time and needed to optimize it. I read some articles about optimizing my game and it says that once you instantiate the prefabs in the ...
1
vote
2answers
16 views

GetComponentsInChildren<GUIText>().text - does not contain a definition

My Slider GameObject has a GUIText child. I am writing a C# script that should change the text component in the GUIText, but instead of this I am getting: error CS1061: Type UnityEngine.GUIText[]' ...
-3
votes
2answers
38 views

How to make an OnCollision reset level script?

I am making a game and I want to make a script that if a player collides with the resetting object the scene will reset/reload.
0
votes
0answers
37 views

How to keep my player in center of path.?

I want to keep my player in center of the path. I have different paths like strait and 90 degree rotated. I want keep my player moving in center in center like temple run also when I rotate my player ...
0
votes
0answers
16 views

Can`t login in twitter with Fabric! [migrated]

I use fabric for Twitter Share function in my Unity game (Android). I follow all instructions, but I can`t authorize in twitter. But i have my app on dashboard in my fabric account! Full code: ...
1
vote
0answers
16 views

UNET Performance of (many) Kinematic Rigidbodies

I am building a game in Unity in C# using the UNET networking elements. I am trying to figure out what is the performance cost of kinematic rigidbodies? My understanding is that, when kinematic, ...
2
votes
0answers
22 views

Unity3d Isometric moving forwards

I am making an isometric game using unity 3d and 3d graphics. I have been able to figure out how to create and isometric camera that follows the player, and a basic isometric moving script for the ...
1
vote
0answers
27 views

How can I get UI element over which pointer is in Unity3D?

I can detect if mouse is hovering any UI element by EventSystem.current.IsPointerOverGameObject(). But how do I know which GameObjest it is exactly? I have tried: if (EventSystem.current....
1
vote
0answers
14 views

How to add all MonoBehaviours of Scene into the List?

I've read an article 10000 UPDATE() CALLS. Author uses UpdateManager. It has Update method which calls Update method in all of other MonoBehaviours of objects. It works faster than calling Update ...
1
vote
0answers
24 views

How can I create click and drag for a 3D Jenga game in Unity?

Essentially, I am trying to create a game that mimics Jenga. Right now I have made it so that the blocks collide with each other and have gravity, everything works very well. The one thing that I am ...
1
vote
0answers
22 views

Top down controller script trouble

My game features a top down camera that follows the player as he moves via virtual joystick on a cellphone screen. I want the movement of the player to always walk forward and the direction will be ...
1
vote
0answers
19 views

Unity 2D animation running partially

I have a 2D skeleton animation of human walk cycle - which is fine. I am trying hard to code that should STOP only hands animation but legs should not (on a player input - for example on space bar ...
1
vote
0answers
27 views

Game logic implemented using TPL / async / await, and performance of it

I'm working on a game, and as a typical game (here using Monogame) it uses frame based approach, where all logic happens in Update() method called every frame. As a consequence, any sequential logic ...
2
votes
1answer
51 views

How can I create a copy of an object in Unity?

I'm new to unity. How can I make some copies of my GameObject in Unity by scripting? I have tried this by the way: public GameObject stone_3; void Start () { for (int i = 0; i < 10; i++) ...
1
vote
1answer
40 views

UI 5: Slider Pressed

I am using the UI slider from Unity 5 and would like to display a text every time the handle knob is touched/pressed. My understanding is that my script should extend some Event System interface. ...
1
vote
2answers
41 views

Camera relative movement is pushing into/off the ground instead of parallel

I'm building upon roll a ball tutorial in unity, and I have managed to rotate the camera around the ball just fine with the code below. But there's one problem. In this code, when I add force to the ...
1
vote
1answer
34 views

convert clock input into 24 hour format

I have stuck in a logical problem I have a third party package of DayNight. It takes hours input(24-hour-format) to show dayNight effects in scene My code is to transform 12 hours clock cycle into 24 ...
1
vote
0answers
36 views

Position values magically flipping signs

I'm trying to make a 2D sliding puzzle game (like 15 puzzle). My main problem is getting the squares to stop just before they touch. I don't want to use colliders because I'm scared they might pop out ...
0
votes
2answers
71 views

Prefab Instantiates into scene, but when I store a reference to the instance it's null

I am instantiating and parenting two objects - the first is a Unity primitive and the second is a prefab cube (literally nothing but a cube made into a prefab). The direct instantiation of the ...
1
vote
1answer
66 views

Why do I get an infinite loop created by a subtraction in Unity3D? [on hold]

Does anyone have a solution to this ? When I do the subtraction , it makes a loop that does not stop. if ((lamp.activeSelf == true)&&(test == true)) { money = money - 50; /...
1
vote
2answers
45 views

Unity2D - collide with objects while moving to a position

How do I get my character to collide with other objects while moving to a position? All I've managed to do is change the position, it only collides if the character is not moving, it's like he is ...
0
votes
0answers
17 views

Toggle between function in unity [on hold]

I want to toggle between function with the left mouse click. So basically, I want my the screen to start with displaying func1(func1 is activated), then when you press the left mouse buttonfunc1 gets ...
-1
votes
0answers
32 views

Best way to implement card effects for a TCG [closed]

So, I have been wondering for some time how people code different card effects for the various TCG card games that are available now. After thinking about how I would implement this, I came up with ...
-1
votes
0answers
41 views

Why does my code crash on sign-in with Google Play? [closed]

I just updated GooglePlayGames plugin for Unity. My code worked fine before I updated the plugin but now my game crashes on sign in. public class Signin : MonoBehaviour { void Start () {...
1
vote
2answers
34 views

Replace PolygonCollider2D with MeshCollider at runtime

I am using a PolygonCollider2D to load in points for a MeshCollider at runtime, but am having issues switching between the two at runtime using good coding practices. This is a simplified version of ...
1
vote
0answers
33 views

My orbit code produces the wrong results

I have a GameObject called "Sun" in the sky. A game object called "GameManager" keeps track of time in the game, it is responsible for updating the hours and days. For my sun I do something like this ...
1
vote
0answers
33 views

I keep getting a type/namespace error when I try to define my two motion controllers. What am I doing wrong?

I'm trying to get motion controls working (particularly making it act like a joystick) but I keep getting this error "The type or namespace name 'SteamVR_Controller' could not be found (are you ...
1
vote
1answer
36 views

How do you get audio clips to play on all clients?

I am new to networking with so this is probably a noob question. For context I am trying to get a gunshot sound effect to play and be heard by all players.
1
vote
1answer
97 views

Programmatically change combination of sprites

I am a total newby to unity and cannot figure out how to achieve the following: I want to show a picture composed of different sprites. E.g., a pen with four binary features: the pencolor (black or ...
-1
votes
1answer
83 views

create continuous snake like slither.io MonoGame c#

I need help creating a snake with continuous smooth motion like slither.Io up till now I just can't find any but the grid snake. EDIT: Following a curve with the snake, Grow that snake.
1
vote
1answer
62 views

Need Help With My Script And Animator. I am encountering a few bugs with it

Okay so I have created a player archer character which when he using the arrow keys, faces those directions and upon hitting space when in that direction, the bow attack animation is played. The code ...
1
vote
1answer
13 views

How do I get the InputManager to recognize a certain axis/Vector2D with a Vive motion controller?

Right. So basically I want to map the Vive motion controller touchpads (certain locations) to the certain inputs in Unity's InputManager. How do I do this? Like I want a certain area on the touchpad ...
-3
votes
1answer
82 views

best way to handle when a game is active?

I'm facing a problem with a game I'm making on C#. I have a status for the game to decide if it's active or not. However, there are many moments when it must be paused don't have focus a menu is ...
0
votes
2answers
30 views

How can I get all components of a type from a List with mixed components?

I have a list of GameObjects. Half of these GameObjects have Component1, and the other half have Component2. I want to get all of Component1 from the list. So an example of my list: var list = new ...
3
votes
1answer
25 views

How to edit and persist serializable Assets in the Editor Window?

I have an asset saved in my project which represents a serializable scriptable object. Code of the object is very simple: using UnityEngine; using System.Collections; public class TestScriptable : ...
1
vote
1answer
44 views

Print string letter by letter in UI Text

i'm trying to print a string letter by letter for UI Text of Unity. With each click of a button, the Stampa function, must print a letter. Up to this point everything is working perfectly. But if I ...
0
votes
2answers
49 views

smooth loading of the heavy scene in unity3d

I have a very very big/huge scene to load, I can't load it at once. So what I know I have applied but it still loading takes some time I want to make it smooth. How it possible? What i have tried so ...
0
votes
2answers
51 views

Random Functions in Unity [closed]

Is their a way to execute or call a random function in unity. Something like:- void Update(){random(func1(),func2())} void func1(){print("func1")} void func2(){print("func2")}
-1
votes
0answers
34 views

Toggle between positions in Unity [closed]

I am making a 2D game where an object goes up, down or in the middle. I want to toggle between going down, middle or up on left click but it is not working. So basically what is meant to be happening ...
-1
votes
1answer
53 views

What properties should be private, public, and protected? [closed]

I'm currently trying to write a base player class, and I'm not exactly sure what I should make private, and what I should make public. I know that as a programmer, I need to keep as many variables as ...
1
vote
1answer
84 views

Creating a list of buttons dynamically in code

I have a list of contacts. I need to create a scrollable list of buttons that are created dynamically so I can add each contact name as the button text. How would I do this all in code? My biggest ...
0
votes
1answer
54 views

Move around object

I have problem with Unity - 2D objects. I want to rotate object around circle and on click translate it (with same angle) outside the circle to another and still rotate. Rotating is working with ...
0
votes
1answer
31 views

Transforming position in y-axis (going in the middle) in Unity [closed]

I am making a 2d game where an object goes up, down or in the middle with given Input. But when the object goes to the middle with GoMiddle() it starts glitching and it can't go back up or down ...
0
votes
1answer
32 views

2D diagonal movement using Rigidbody2D

I have a problem with 2d player movement, as I am unable to move on the Y-axis. Yet, the movement on the X-axis is working as intended. Below, you can see my code: public Sprite directionUp; public ...
1
vote
2answers
42 views

Randomly instantiate avoiding overlapping in Unity 5

I'm starting a 2D game where I want all the letters A-Z displayed in a random position and, then, the player collects them all in the correct order. I need to randomly instantiate the letters without ...
1
vote
1answer
34 views

Programatically Build List of Custom Class Objects (prefabs)

This seems like it should be a simple thing, but I cannot seem to figure out a method. Currently, I have a public List<MapGraphItem> roomList variable, and in the inspector, I add prefabs from ...
1
vote
1answer
47 views

Unity Rotation - Object is rotating on Z, but should be rotating on X

I've been working on a project where I have a cube. When swiped left, the cube will rotate 90 degrees the left, and then when swiped right, the cube will rotate 90 degrees to the right. I have this ...
1
vote
0answers
29 views

Problem in player Rotation in Unity

I am trying to rotate game camera using my android device orientation.Like this Using accelerometer input of device this may be done. But I don't know how to do this. I tried lot of methods, but ...
4
votes
1answer
81 views

How do I differentiate between the two Vive motion controllers?

I am working with a Vive Pre (devkit) and I have most everything working the way I want it to. However I am wondering how do I refer to or even know which motion controller is which? From what I can ...
3
votes
2answers
72 views

How do you restrict sideway movement in 3D endless runner in Unity?

I have been making a endless runner 3d game and implemented 3 lane side way movement. It's working perfectly, although I want to restrict my movement for the 3 lanes only. If my character for example ...