In this article, I am going to go over the implementation of the new enemy I have introduced. The minelayer.
The enemy circles down the screen while dropping mines at random intervals.
The mines will gravitate towards the player if they get too close so this enemy I one who causes a lot more hassle later in the game when in bigger numbers as they can render the field difficult to maneuver
In order to prevent repeating code for any more future enemies, I have refactored the initial enemy into an abstract class.
The minelayer enemy is just an alien spaceship asset I download and converted to 2d.
I used a sine and cosine wave to have the enemy circle its parent game object (which moves slowly down the screen). I won't delve into the maths behind it but remember SohCahToa from school to help decide which wave have you need to assign to each vector.
Now, this enemy is moving I just needed to assign a simple script to have the parent game object move down the screen.
The role of this object is to take up space and slow down the player (and cause damage if the player gets too close).
The mine will move towards the player as soon as the player gets into range and will continue to chase (slowly) until the player moves out of range. The player can destroy these objects with any weapon. If the mine touches the player it explodes and causes damage.
Now we can see this object in action.
That’s all for now.