Clean it up! — Using containers in Unity

Jack Leavey
May 26, 2022

In the previous article we discussed how to set up a spawn manager, but in it’s current iteration it floods the hierarchy with all of the new enemies as the spawn!

Thankfully, it is easy to have those enemies spawn in another empty gameobject by using the parent/child system.

In the last article, we made a public gameobject variable with the name “enemyContainer”, but did not utilize it.

Inside our spawning coroutine, we are going to assign the local NewEnemy variable to be a child of the enemyContainer variable.

To see the rest of the code, check out my previous article.

Now our enemies spawn into this container which can be minimized at will!

Simple and efficient parenting.

--

--

Jack Leavey

I am a software engineer with years of experience branching into game development, specifically in Unity. Follow along for guides on creating game mechanics!