Creating Boss Enemy Part 2!
Objective: Set a sprite for the boss enemy, health.
We have a boss cube that shoots our player to death. Great! Now we need to decide on what sprite we want to use to represent the boss, better than a cube. If you are following along, feel free to use whatever asset you have at your disposal. For me, I’m going to use a larger scale enemy.
Since I’m using the same sprite as a normal enemy, I’m going to change its color. This will give the boss a visual difference to go with the behavior differences.
You may need to adjust your code for the y axis to better suit your asset. This way the boss will still land on the screen where you want it to hover.
This makes your boss look complete. If you look closely you notice, it’s not. The boss as of now, looks cool, shows up and shoots your player to death. The player has no way of damaging the boss. Let’s change that.
To begin we need to create a variable to represent the boss’s health.
If you have not done so before now, add a rigidbody and a collider. With the larger scale enemy, we will want to edit the collider, so the player must be more precise with their shots.
Inside the boss script create an on-trigger method. Set two if statements, one for each type of weapon the player has.
Next is a damage method with int parameters. We want the missile to cause more damage than the laser. With the laser damage set to 5, it will take 20 shots to destroy the boss.
The boss can now be defeated. We’ve done it, we have almost finished our game. In the next part, we will set the boss wave to be generated in the spawn manager. We also need to set some damage animations to the boss. As I always say, never be afraid to experiment with your code, and I’ll see you in the next Tutorial!