Learn to code by making 2.5 D Space Shooter

Suleiman Abdullah
2 min readNov 24, 2021


Objective: Add SpawnManager to our space shooter

We want to Spawn Enemy as along our Player is Alive, we will spawn enemy Prefab at every 5 seconds at random position.

The First Step lets create SpawnManager script and attach to Empty GameOBject named Spawn_Manager .

To spawn enemy every 5 seconds we use coroutine , this is method allow to pause execution and return control to unity but then continue where it left off in the following frame.

But in order to spawn enemy continuously we need to instantiate our enemy inside while loop.

Infinity loop true is always true so it will never get out of the loop

Then lets Instantiate our enemy prefab every 5 seconds, so we need to know about create reference a variable to Instantiate then Instantiate.

Now lets randomize our Enemy prefab

Next step is to drag our reference _enemyPrefab to a SpawnManager on the Inspector.

Note: never use instance of prefab from hierarchy for Instantiate.

Lets see if our Enemy successfully spawned every 5 seconds.

The reason for this is we need to initialize our coroutine other wise it wont work.

This is how we successful add SpawnManager to our Space Shooter .



Suleiman Abdullah

Self taught Unity Developer, who is passion about making games ,and he loves Math For Game Development