Spawning Objects Without Clutter
2 min readMar 28, 2021
When Instantiating game objects in Unity it is easy for the hierarchy to become cluttered with cloned game objects. This can make it hard to look through the hierarchy and find anything. To prevent this it is a good idea to parent instantiated objects that you know will have multiple clones.
To do this:
- Create an empty game object in the hierarchy
- In the script that is instantiating the game object create a reference to the empty game object
- Create a game object variable when you instantiate the game object
- Now make the empty game object the new parent of the instantiated game object
When doing this make sure to use .transform when setting the new parent. You have to do this because you are assigning the parent to the game object which is not the same variable type so you need to use .transform to match variable types.