Creating a boss battle, part 2
I’m back at it again, comin’ at ya’ with some funky fresh, heart-stopping, boss-making action. Today, I want to give the boss some shields and also give it weapons.
I’ll start with the shields. I want the boss’ shields to be up while moving so the player can’t just unload a barrage of lasers and destroy it easily. Once it stops moving, the shields will go down and the boss will be vulnerable. I added my shield prefab as a child of the boss and changed the color a bit to differentiate it from the player’s. Then in the boss script, I made a new variable to store a reference to the shield. In the movement routine, I’m setting the shield to be active before the code to move the boss then setting it back to being inactive when the movement is complete. I also added a condition to the collision logic to make sure damage is only calculated when the shields are not active.
I created a new prefab laser specifically for the boss, and reused the existing laser script. To implement the firing feature, I reused the same code from the enemy’s firing logic and sped up the reload time. I also randomized where the laser will spawn, since the boss has multiple cannons on the front of it.
Next, I want to add another, more dangerous attack for the boss and also create functionality to end the game when the boss is destroyed.