Tidy Up the Spawning- Game Dev Series 12

How about keeps the children to where the parent is?

Previous: Makes it Keep Running with Coroutine

After we created the spawning machine, one issue pops up immediately. As the player lives the longer, the game environment gets much messy.

I’m not just talking about the gameplay, but also the hierarchy.

All the enemies spawned at the root of hierarchy which is really not easy for us to maintain, especially when you add more contents in the future.
We need to store these gameobjects into another empty gameobject. In Unity, we called this “set a parent”.

Let’s create an empty under Spawn_Manager and called it Enemy Container.

Let’s create a variable to tell the script what is Enemy Container and add a line.

Before we add a line to it, how do we give an order to a gameobject just spawned?
Even a gameobject not yet been created, we can still make a variable to it.

Set a GameObject variable named newEnemy. Then we can set the parent to it.

Now it should know where to put the spawned enemy when played the game.

--

--

--

A passionate gamer whose goal is to work in video game development.

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

Recommended from Medium

CS373 Final Entry, Spring 2021

Programming Language Comparison Chart | Python vs. JavaScript

How to Upgrade All Python Packages with PIP in 2022?

Innovation: what is it?

Coding for kids: Top buzz in 2020

Understanding DevOps

How to create a local copy of your WordPress website

How to Set up VSCode for Development of Spring Boot Services

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
S.J. Jason Liu

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

More from Medium

How to Alter Your Pre-Built Texture Maps

Adding Post Processing Profiles in Unity- Game Dev Series 155

Simple Player Movement in Unity

How to Create the Hand-Held Camera Look on Unity Cameras using Noise