Boss battle phase 2: Spawning additional enemies during the boss battle.
Some little enemies are gonna help the boss
Objective: start spawning regular enemies when the boss gets 10 hits.
First in the boss script using the OnTriggerEnter2D function we have to check if there is a collision with a laser. Within the condition we destroy the laser and check if the hits on the boss are greater than 10.
When the boss gets 10 hits we check with a switch statement the current phase of the battle and at that moment I just let some comments to know what I have to add in each case.
To spawn the enemies I created a variable to store the reference to the enemy prefab. Next I created a coroutine to Instantiate that prefab in a random position each 5 seconds.
Then in the switch statement we created before I start the coroutine when the value of current phase is equals than 1.
And that’s it!!! Now the boss battle is more complicated.