Unity/C# Challenge 33: New Enemy Type

Alec Oney
Oct 12, 2021

Challenge: Create a new enemy for our wave system

Now that we have a rudimentary wave system in our game, we want to create an elite enemy for our later waves. First, we copy our enemy prefab, remove the script, rename the object, and recolor it:

Then we attach a new script to the elite enemy; we will copy the enemy script to this one, attach the relevant GameObjects (the laser prefab, in particular), and then modify the script in the following ways:

in void start:

where randDir is a private int, and the startFiring coroutine is modified below

startFiring is modified:

and CalculateMovement is modified:

Then, we will modify our SpawnManager script to include our new elite enemy:

our enemy prefabs are changed to an array

and our spawn routine:

now, we have an elite enemy with a different movement type, as well as burst fire, that will spawn in later waves of our game.

--

--