Questions tagged [gameobject]

GameObject is a key component of the Unity3D engine. It is often associated with Unity3D questions.

GameObject is a key component of the Unity3D engine. It is often used in the engine when developing games and apps. It can be added to a Unity scene to represent and control many game elements such as UI, audio, effects, lighting and various objects. The GameObject can have multiple components added to it, including a script to control its behavior and attributes.

708 questions
-1
votes
1 answer

Deselect prefab child object after new selected (same prefab) child object is clicked on in Unity3D?

I have a prefab object that has many children. I highlight any "One" of these children and change its color. I am selecting another child of the same prefab and highlight it by changing its color but at the same time I want the previous child to…
-1
votes
2 answers

Unity Extension Method GameObject

I'm trying to add an extension method to my gameobject, that's works, but my problem is the GameObject share the same result. My goal is to have a different result for each GameObject. // AddExtension.cs public static class GameObjectExtensions { …
twenty94470
  • 105
  • 2
  • 12
-1
votes
1 answer

Access gameobjects properties from collider

So I have a missile. When it hits its target the missile explodes. The explosion has a radius, inside which may be many enemies. The enemies have a "scripted/public variable" explosionPrefab. I find all the enemies using colliders in MissileMove…
T4NK3R
  • 4,245
  • 3
  • 23
  • 25
-1
votes
2 answers

How to use a local object before it is declared?

I am making an if statement and I am trying to check if a game object exists, If it does exist I want to destroy it and then recreate it. If it does not exist I want to create it. I get the error cannot use local variable before it is not…
-1
votes
1 answer

why wont "transform.position = new Vector3(x,y,z)" reset my object's position?

I'm trying to get an object to move along a path and reset/move back to a starting position, ready to move down the path again. The line in question reads sign_obj.transform.position = startpos; but it doesn't work even tho the debug line after it…
BlackRece
  • 1
  • 2
-1
votes
2 answers

UNITY Rigidbody causing my gameobject to continuously move coordinates

I have a cube placed at 0, 1 ,0 and once the program is started after testing I found that rigidbody's gravity is causing my cube it continuously moving around coordinates when it actually isnt moving in the program. I could be clicking absolutely…
jonesmax
  • 85
  • 1
  • 1
  • 6
-1
votes
2 answers

unity 5 c# enable disable gameobject script

Hi I new coding in c# & I working on a script to enable / disable a Unity 5 gameobject clicking on another object for both actions, the first part runs ok, but in the second part to re-enable the object show me this…
Franciscø
  • 21
  • 2
-1
votes
1 answer

Unity3D moving all child objects with parent object

context to the problem: I've got multiple sorts of cubes set up, placed in an array. I've made it so every different cube has his own parent, so all the cubes are grouped together with the other cubes of the same type. I'm trying to move all the…
Sten Martens
  • 61
  • 1
  • 6
-1
votes
2 answers

How i can destroy an GameObject but also store the gameobject in a variable

When i pick a item in my scene, it calls the AddItem() method, and this method would add the item to an List and destroy the gameObject from the scene, but when i try to acess the gameobject in the list this error…
Nícolas
  • 406
  • 3
  • 8
  • 24
-1
votes
1 answer

How to draw on a 3D game object in Unity

I have a 3D cube (game object with material) in my Unity 3D application (C# scripts). If the user clicks the cube, I want a small red circle drawn on the cube at the exact mouse position where the user clicked. The cube's position may change as it…
Nullqwerty
  • 1,140
  • 1
  • 20
  • 37
-1
votes
1 answer

how to make the GameObject have a parameter in unity (c#)?

please help me how to get the value of "currentPeople.timeCount;" for example i have a script: public class BuildingPlacement : MonoBehaviour { public GameObject currentPeople;public int DelayTime;private int timeCount; } if i want to say that…
-1
votes
1 answer

How To Arrange a Desain Gameobject or UI to become Scrollable using Scroll Rect ? Unity C#

Please help me.. How to arrange gameobject or UI to become like the screenshot and make it scrollable using scroll rect ? The UI must be arrange like screenshot. There is a border yellow contain the UI and it must be scroollable. and then there is a…
Dennis Liu
  • 303
  • 5
  • 21
-1
votes
1 answer

How to move game object up at constant speed? It is not responding to gravity

I have this code, and I had moved my game objects in my old code just fine, but in this code my player doesn't want to move up or down. Even If I select "UseGravity" in the rigidbody settings, the game Object just won't move down! What is the…
Anton nelson
  • 333
  • 3
  • 8
  • 18
-1
votes
3 answers

Unity Object Always Instantiating at 0, 0, 0

I am trying to make simple terrain generation in my Minecraft clone. Whenever I try to run the script, it places ALL the instantiated objects at the position 0, 0, 0. Here is my C# code for terrain generation: using UnityEngine; using…
-1
votes
1 answer

Change variable in script thats attached to many gameObjects?

I've been trying to implement this to my Unity 2D game but can't get it to work. While digging through API I've seen this Object.FindObjectsOfType.html but how do I use it in my case? I have an JS/UnityScript script called "InventoryHandler" which…
Amar Kalabić
  • 888
  • 4
  • 15
  • 33