Step 5.5 — Organizing Enemy Spawn Clutter
In the previous article, the coroutine will spawn enemies indefinitely so long as the player is alive. There’s nothing wrong with this, but the Unity Hierarchy might start to get cluttered, which may be a problem if you want to say, find a object in your Scene while you pause the game. We probably don’t need to see all these Enemies in the Hierarchy, so we can put them into a container.

Create an empty object under the SpawnManager. Name it Enemy Container.

In the SpawnManager script add a new GameObject variable to set as the Enemy Container in the Inspector, and tweak the enemy spawn coroutine a little.

When the enemy is Instantiated it is immediately assigned into the variable newEnemy. As a variable you can now set its parent object to be the Enemy Container object.

Now all the enemies created are neatly placed into the Enemy Container.