GameDevHQ Crash Course #16 More Enemies
Beginning 2D space Shooter-Extra features -Enemies
Ok quite a bit to add to this one, first we added some shields to certain enemy types, which will be spawning in waves on the left and right. Some Enemies that track to the players position and speed towards them, the ability for enemies to shoot backwards if the player is above them, enemies shooting at the players powerups if they are below them, and finally a boss.
For the waves of enemies we built ourselves a modular wave management scripts, this way we can make multiple different waves of enemies without having to make a whole bunch of different scripts. so this one takes 1 enemy type, and a bunch of positions on the screen that the enemy is going to pass.
This is what our it looks like in the unity editor so I can just drop a enemy in and a set of way points, how many enemies that wave will spawn and how fast the enemy will go. then in our enemyspawner script this will all be used to order spawning of waves of enemies and after all enemies in waves are spawned, spawn ourselves a boss enemy. Then rinse and repeat.
We also added a shield to some of those waved enemies that break after a hit, just to keep them moving a bit longer.
Enemies Destroying projectiles just set the ability for their lasers to also hit projectiles and not just the player.
Enemies avoiding shots took a bit more work , trying to work out how to go about getting the laser directly underneath and then though of a better solution
This is a event set up, so when the player shoots, it sends out a call to all the scripts that request that call and sends the x position in this case, so if an enemy is on the same x position as the player when the player fires, it will attempt to move either left or right to avoid the shot.
For the enemy rammers , had them find the players position on spawn and move towards that instead of just down , when the player is above them they resume moving downwards, as the player doesn’t have a way of shooting down it would be unfair for the enemies to come back up.
Finally the boss, this one I added new weapons to, a double laser that fires every few seconds and then a laser that it stops and fires before resuming its path.
This is what that all looks like in a more complete loop. A lot more hectic of a game then before, the boss also has a visible health bar that we used the same way as the booster, updating a UI slider that has the knob removed nice and simple! also added a bit of screen shake to give some player feedback that they are taking damage.