We have our Boss moving, but now it’s time to make them more dangerous by giving them some shooting abilities!
My Big Bad Boss will have the ability to shoot fireballs that explode, and also Freeze Asteroids to slow the Player down and make them more vulnerable!
The Boss’s Fireball is actually just a reuse of the Kamikaze Enemy’s bomb with different settings and an extra animated sprite.
All the pieces in the new Prefab:
The EnemyBomb script that is attached to the main Boss_Fireball parent:
Boss Fireball in Script
Now for the logic inside the EnemyBoss script. First we need some global variables (which are almost identical the regular Enemy firing function):
And inside our Update() function (or inside a new function called within Update()) we have our firing logic:
Now our Boss will shoot Fireballs randomly between 1 and 3 seconds!
Dropping Freeze Asteroids
Dropping the Boss Freeze Asteroids could be done the same way as the Fireballs, but I chose to show you another way to shoot/drop projectiles; through a coroutine!
Here’s the link to creating the Freeze Asteroid Prefab: https://medium.com/nerd-for-tech/negative-pickup-freeze-asteroid-30b3582dc9f2
Like always, first some Global variables to work with:
Then we’ll create the coroutine:
This time, the random drop time is between 1 and 5 seconds, plus an additional half second variance.
Now we can start this coroutine in the Start() function:
The last thing we do is to make sure we link both prefabs to the correct slot in the Boss Enemy Inspector!
That’s it! Nothing too crazy, but in a short amount of time, and by using two different methods, our Boss Enemy now shoots some projectiles and makes them that much more dangerous!
In the next article we’ll cover the Boss’s defense mechanism — it’s Asteroid Belt shield/attack!