Day 5 — It’s been a while()

Chelsea Cruise
May 12, 2021

--

Objective: We now need to spawn enemies in our game efficiently.

How:

I’ve created a null object in my scene.

Spawn Manager Null in Unity

In it’s script, I’ve created a While() Loop within an IEnumerator and labeled this method ‘SpawnRoutine()’.

IEnumerator SpawnRoutine()

From here, we’ll instantiate the Enemy game object and tell it to spawn every 5 seconds randomly using yield return WaitForSeconds() & Random.Range().

WaitForSeconds, Random.Range

This will create an effective system for spawning our enemy players as I’ve done so below:

--

--

Chelsea Cruise
Chelsea Cruise

Written by Chelsea Cruise

Unity Developer, Software Engineer, Game Designer, Graphic Artist

No responses yet