Step 5.5 — Organizing Enemy Spawn Clutter

Nicholas Lim
2 min readApr 9, 2021

--

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.

Imagine 10, 20, 100 Enemy(Clones)

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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response