Spawning Items in Unity for Neatness

Hard mode!

Containers

If we start putting all of our enemies into the enemy container we can access them a lot more quickly, and we can find other objects in the hierarchy more easily too. An easy way to do this is using an empty game object. Then whenever we create an enemy, we can tell it that this empty game object is it’s new parent.

Are you my parent? Yes I am.
Neat and Tidy.

Prefabs for Prefabs

This works in a similar way. But when you need to create a group of objects on a consistent basis, just create a new prefab that contains all the other prefabs.

Shoot one get two free!

Cleanup

We already have covered deleting objects when they aren’t needed but the containers can also be deleted as well. Here is a great way to detect when a parent container should be deleted, when there are no children!

--

--

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