Day 15: Spawning Objects in Unity without the Clutter
Objective: Cleaning up the Hierarchy
The first thing we will need is a container to hold all the enemies that are still alive! Right click on Spawn_Manager and create Empty
Now to enter the SpawnManager Script. Here we need a reference to the EnemyContainer.
In the IEnumerator that was created yesterday, we need to turn the Instantiate into a game object called newEnemy.
What we will do now is set the newEnemy as a child to the Enemy Container. We do this by setting the newEnemy’s transform.parent to the enemyContainer.transform.
This is an easy way of keeping the Hierarchy clean and no filled with tons of the same game object being spawn again and again! Don’t forget to assign the object in the inspector.