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
4
votes
1 answer

Matching objects in a drag and drop game

I am developing an educational game where I give the user a selection of words. The objective is to take these words and arrange them into a sentence by dragging each word individually and placing it into order on the provided area. I have an plane…
caubry
  • 260
  • 4
  • 13
4
votes
2 answers

Changing TextMeshPro Text which is child of 2D Sprite via script in Unity

I have a 2D square object sprite that has a child TextMeshPro object which stores a number. Hierarchy in Unity: Unity Scene: I want to dynamically change the number in the TextMeshPro object via a script that is a component of the 2D square…
4
votes
1 answer

Unity: 3D movement/Collision detection failure (AddForce, MovePosition, transform.localPosition)

Problem: If I get the movement to work correctly, then the collision meshes are not detected. If I get the collision meshes detected, then the movement doesn't work correctly. Brief summary of project: I have a 3D environment with non-moveable…
user70711
  • 131
  • 1
  • 9
4
votes
2 answers

How does Unity decide which Component to return when calling GetComponent on a GameObject with multiple components of type T?

If I have a GameObject with multiple Component classes attached to it of the same type (let's call this type HingeJoint for example purposes), which HingeJoint component will I get if I called the function GetComponent() on my…
Jimmy Huch
  • 4,400
  • 7
  • 29
  • 34
4
votes
1 answer

GameObjects in a public static Dictionary are destroyed on scene changes in Unity

First formal declarations: Programming Language: C# in Unity (MonoBehavior) My skill level: Kinda noob (less then half a year c# experience). I am making a block breaker game (Arkanoid) and are making an acheivement system. The game is one-shot,…
4
votes
1 answer

Unity 5 NullReferenceException after loading new scene

so I'm doing my first fps game and now I'm at the point of going from the start menu to my first scene. When that new scene loads, on the awake, in my pause game script, I set the pauseMenu.SetActive(false) (it's a Canvas and the pause game script…
Manu
  • 65
  • 1
  • 2
  • 8
4
votes
2 answers

How to control instantiated prefabs at runtime as children

I have a game in Unity where I instantiate GameObjects every few seconds. Then in the Hierarchy, the prefabs show up in a list of them being instantiated e.g.: EnemyBlue(Clone) EnemyRed(Clone) EnemyGreen(Clone) EnemyBlue(Clone) Which clogs up my…
user5470869
4
votes
1 answer

GameObject.FindGameObjectWithTag returning (clone)?

im having this problem and its when i use GameObject.FindGameObjectWithTag("red"); it started when i added an animator component to the gameObject its returning red(Clone) when the game object is in the heirarchy as the only gameobject with the…
JRowan
  • 6,824
  • 8
  • 40
  • 59
4
votes
1 answer

How to update Unity GameObject to move along Spline Curve?

Good afternoon, I am attempting to implement a GameObject in Unity that moves along a Cubic CatMull-Rom Spline given 8 constrained random values. I have implemented a function, ComputePointOnCatmullRomCurve, that returns a point on a cubic…
4
votes
2 answers

Unity/C# Find object and get component

This should be an easy one: GameObject myCube = GameObject.Find("Cubey").GetComponent(); just kicks up error CS0309: The type UnityEngine.GameObject must be convertible to UnityEngine.Component in order to use it as parameter T in the…
Ghoul Fool
  • 6,249
  • 10
  • 67
  • 125
4
votes
2 answers

An error occurs when trying to set a child to my GameObject in script

GameObject enemy = Instantiate(spawnObject,spawnPosition,spawnObject.transform.rotation) as GameObject; enemy.transform.parent = transform; The above code generates the expected result when I test my game in game mode, however I'm gettting this…
3
votes
1 answer

Check If active Multiple gameobject

I looking for a way to check multiple gameobject (numbers) and 5 parts to display, every part have 3 numbers they display random (0 is in all part), if O active in part1 do not display 0 in part 2,3,4 and 5 again but randomize another numbers in…
betrice mpalanzi
  • 1,436
  • 12
  • 16
3
votes
1 answer

Unity3D: Convert all game objects to same size irrespective of it's scale

Suppose I have a reference GameObject, Cube, with scale (1,1,1). There is another GameObject with scale (1,1,1), but the size is 3 times bigger than the Cube. How do I dynamically change the scale of the Game objects to fit the size of the Cube?
MrRobot9
  • 2,402
  • 4
  • 31
  • 68
3
votes
3 answers

Unity LineRenderer - unable to set positions

This links to my previous question about being unable to get a reference to a Unity LineRenderer. Got round that one temporarily, though still do not understand what the problem was. But now, having got the LineRenderer reference, cannot do anything…
nmw01223
  • 1,611
  • 3
  • 23
  • 40
3
votes
3 answers

Attaching Unity Scriptable Object to GameObject

I have been doing Unity tutorials for about two weeks now and I have made some very basic things. Sorry if this is a super simple question, but I have spent the last 5 hours working on this and decided to come here. What I have done so far: I have…
GorillaMan33
  • 35
  • 1
  • 1
  • 3
1
2
3
47 48