Week 4 – The Third Enemy

third-enemy
The Enemy with placeholder sprites

This week I have been working with our third enemy and some small refinements on a few things like making the camera work in parallax and getting knockback on the powerup for the player.

For the third enemy we wanted a much more harder enemy that could shoot and be able to take a few hits from the player’s base weapon.

So the enemy would be big and slow moving as well be able to shoot projectiles in eight different directions.

As the other enemies making it move was just using the same base script of having a velocity in one direction. Having a score value for it was also to just put in a similar script.

So I needed to create an projectile for the enemy to shoot, adjusting a prefab of one of the players bullets I made it so it self would have a set velocity.

The enemy would shoot in different directions so I made spawn point for each of them in Unity and instead of having the bullets have different velocity directions I simply rotated the spawn points at set degrees to have move in the desired direction.

For the code I had to make an instantiate for each spawn point and use the prefab bullet in there.

The spawning bullets would move at a set timer and stop spawning after the enemy was dead.

What took time was calculating which degrees the bullets would spawn at, as the eight directions should have a similar distance between them.

For the health of the enemy, using two if statements to have the health countdown on each hit from the player’s base weapon.

All the values can be easily changed inside unity as the the fire rate and healt number needs to be refined for the final product.

All the parts needs to be destroyed after exiting the playing area so having a script on all of them to be deleted after moving out of a set range was implemented however some of the bullets that got shot out didn’t get deleted so I set up so that after moving out of a collider that is around the whole playing area it would be deleted instead of the other ones..

Making this enemy got me to think about reducing assets for all I’ve done as I realised that you could make different things happen with using the same part and barely change anything.

About Baloo Beckman

2016 Programming