Spawning Objects in Unity without the Clutter

Previously using the Coroutine method we were able to get enemies spawning, this created a lot of gameobjects within our hierarchy.

to clean this up while are game is running we can make these gameobjects spawn within the spawn manager as a child and within a container.

This is a empty object created within the spawn manager. In the code we will let the spawn manager know it needs this to spawn enemies within it.

linking empty object by dragging and dropping the empty on to the field

we are instantiating game objects into this container now that we have access through this field

then we will want to access the new enemy then access the transform and get the parent to the assign it a new transform

this will make it a child to the enemy container

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store