Spawning Objects in Unity Without The Clutter

spawn manager organization

Objective: Send the enemies spawned from the spawn manager into a container to organize the scene.

The first thing we need to do is create an empty game object inside the Spawn_Manager and name it Enemy_Container.

create Enemy_Container inside the Spawn_manager

Now we need to let our spawn manager know about the enemy container:

Script storage for the enemy container in the spawn manager
Adding in the empty game object

Since we never told the script where to put the created enemies, the enemy clone is just thrown down into the scene cluttering the hierarchy. To fix this, we can assign a variable to the newly created enemies and call it newEnemy.

GameObject newEnemy

The last thing we need to do is tell the newEnemy variable to create the enemy game objects in the Spawn_Container and to do this we can use:

newEneny.transform.parent = _enemyContainer.transform;

Now all enemies created will be sent to a droplist making it much easier to navigate Unity’s hierarchy during the game.




Learning to become a unity game developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

RAII without deterministic destructors

Journey from a noob to an accepted Outreachy Wikimedia intern

How to Use Computational Thinking When You Don’t Have a Background in Comp Sci

Top DevOps Trends For 2021

Where to put application configuration?

Laravel Accountant Package, MyCLI, Development on an iPad, and More — №238

Spillover Zero

Caching in depth & GraphQL

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
Tacoma Johnson

Tacoma Johnson

Learning to become a unity game developer

More from Medium

The Best Way to Bake Lights/Choose Static/Dynamic Objects

Jump Force

Day 3: Layout or Get Laid Out

Learn to code by making a 2D space shooter game.