Unity Tip: Organizing Dynamically Spawned Objects

Marc Hewitt
May 19, 2021

--

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.

--

--

Marc Hewitt

An Austin TX Unity3d Developer with a unique background in marketing, design, & software development leading digital web agencies to success for the past decade