Unity Tip: Organizing Dynamically Spawned Objects

Dynamic objects grow fast and become an issue when debugging

Most people learn quickly how to set an empty Parent object to stash things like Managers and level props. But when spawning objects in Unity such as bullets, and enemies by default it will just spew into your hierarchy making debugging a nightmare.

How to Organize Spawned Objects

The simplest way is to set up an empty object as you would with level props or managers, then add a serialized field for a GameObject. Drag and drop to hook up the folder object to the player variable. Then when we Instantiate the new object we assign the folder GameObject to the object’s parent.

Hook it up with drag and drop
After Instantiate, assign the container to the new object’s parent

Now All Organized

Now as you can see every laser is put into the laserContainer.

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