Adding a Boss to 2D Galaxy Shooter in Unity-Part 03-Boss Weapons!

Chris Hilton
3 min readOct 1, 2021

Objective: To implement the final Boss’s weapons for our 2D Galaxy Shooter.

Let’s give the boss some weapons! A couple of them will already be familiar but I have created a new proximity mine that the boss throws out towards the player and detonates if it is too close. Let’s get into it!

Adding a Simple Laser Weapon

Similar to the player and the basic enemy, we are going to give the boss a laser to shoot with that will be randomly timed. See this article below as we have covered this previously:
https://christopherhilton88.medium.com/instantiating-game-objects-within-unity-61f11538d42d

Adding Quad Lasers

Also similar to the player and the laser enemy, we are going to give the boss 4 of these lasers to give the player a hard time!

Let’s get started with adding a few variables and a prefab that we can instantiate later.

Within Start(), let’s add a time buffer for when the Boss spawns so that it can’t shoot it’s quad lasers for at least 7.5 seconds.

BossQuadFireCooldown() is going to be our cooldown timer for when the boss can fire it’s quad lasers again.

QuadLaserFire() is going to handle the instantiation of the quad lasers and also reduce the bosses energy shield.

Adding a Proximity Mine

This mine is going to spawn from the boss towards the player and follow them for a short period of time before destroying itself if it doesn’t reach the player and if it does reach the player (within a certain radius proximity) then it will explode and damage the player:

Above is the list of variables and components we are going to need.

Now we need to grab the components and of course null check!

Within our Update() method we are going to check if the mine has blown up and if it has set the speed to 0f, if it hasn’t then continue to move towards the player.

Now we are just going to look for a OnTriggerEnter2D() check to see if any of the above have triggered the mine and if so, run the code.

It is going to play an explosion animation, play an AudioSource clip, damage the player (if needed) and then destroy itself after 2.633f seconds so it has time to run the animation.

Next Up: Part 04 — Boss Health and Shield System

--

--