Phase 2: A New Enemy

Objective: Create a new enemy type

For our new enemy we will change the current enemy red and scale it to be slighltly wider and shorter. It will shoot lasers from the front rather than the wings and have an Pulse shield that can take one shot from the Player but deals the same damage as the negative collectable(1 life and up to 5 ammo).

The same initial process with setting up a prefab and lasers as with the previous enemy. The main difference is the pulse shield. For that we set the enemy to have a child object(red ring). The pulse will have a similar logic to the players emp only that it wont expand until it gets destroyed. Instead it will reach a certain width then start from the enemy center again.

Enemy pulse method

We previous set up an isEnemyLaser bool in the laser script. We will use that bool as part of the OnTriggerEnter to destroy the EnemyPulse if the laser hitting it is the players laser.

Destroy laser and pulse if players laser hits

For some spawning balance we set a higher probability of normal enemies than the new red ones.

Enemy spawning probability logic

In the next post, we will look at balancing out the powerup spawning