Working on Enemy type: Shooter

This week I worked on creating one of the enemy types we have in our game which is a shooter enemy. Some of the aesthetic goal successes for our game are feeling massive and mechanical while also not feeling invincible, so these enemies had to be agile, while also being easy to kill if it is hit.

 

CaptureCapture2

The shooter spawns from the right side of the screen, then moves to a certain point on the screen towards the player, stops, shoots an assigned number of projectiles at the player, and then moves up or down randomly. This is done by giving the 2D rigidboby a velocity until it reaches a certain destination, the setting the velocity to zero. After that you instantiate the bullet objects at a certain fire rate, until the ammo runs out. Then you add a horizontal force either up or down. randomly chosen, until the shooter reaches another position, then the ammo gets reset and the process repeats. The number of projectiles the shooter fires, the fire rate, and the velocity can all be adjusted and changed easily, as well as the type of projectile it shoots.

The shooter has a second script that handles the collisions with other entities in the game and also keeps track of its health and destruction. The shooter uses a 2D polygon collider to cover the sprite entirely, and is used to detect collisions with the player projectiles mainly. If the player projectile collides with the shooter enemy, the enemy loses health points corresponding to the damage value on that projectile, but does not destroy the projectile nor alter its trajectory as intended. When the shooters health points reach 0 or lower, the script destroys the shooter and instantiates a death object in its position which is destroyed after a short time by another script. These enemies also have a chance to drop a power-up on death.

The way the scripts are setup make it easy to add different types of shooter enemies in the future simply by adjusting the variables mentioned earlier, or to increase the difficulty of the game later on through the level.

 

About Jad El Masri

2017 Programming