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.

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 as you can see every laser is put into the laserContainer.