Final Boss Implemented!

After days of fixing bugs, I was able to implement the final boss. However, due to some difficulty, in terms of balance or execution, some of the features I wanted to do was skipped or modified.

Player Meeting the Boss for the final battle!

This one was a bit easier than I expected, although it’s more of a workaround than a full cutscene. In order to move the boss into the scene, I’ve set a point on the screen and have the boss move towards it. However, because the boss isn’t firing anything at this point, it’s important to disable movement and fire from the player. I achieved this feature by creating a boolean and setting it to false whenever the boss is entering the scene and setting it back to true when the player can move and fire.

Health Bar showing the Boss’s Health

Implementing the health bar for the boss required a refresher, but was simple after remembering how. In my case, I created a Slider UI game object and because it’s full in the beginning, I set value to the max while changing the color to green. In addition, because the background was longer than the actual fill area, it did require me to decrease the size of the background in order for it to look better.

One of the features I wanted for the final boss was to bounce around the screen while shooting at the player. Initially, I kept getting frustrated on how the boss would move when the game is running. For instance, the boss would fly right off the screen or, like ordinary enemies, just move side to side or continue to move downwards towards the bottom of the screen.

Yet, after doing research on the movement style, the answer I was looking for was already built into Unity: Mathf.PingPong

Mathf.PingPong, in this case, would cause the object to move around the screen like the screensavers found on DVD players. However, even though this would cause the object to bound around, Mathf.PingPong will never go below 0, so this means the boss will only bounce around half of the screen as the screen coordinates on the X value goes from -5 to 5.

In order to overcome this obstacle, I had to use Mathf.Lerp. Lerp accepts 3 values: the start value, the final value, and the value we want to interpolate by. In this case, the start value would be -5, the final value would be 5, and the value we want to interpolate between -5 and 5 would be the Ping Pong value.

On the other hand, because Y value will never be below 0 (due to its large size), I would not need to use Lerp.

Possibly the hardest feature to create is the boss’s special weapon: a huge laser that damages the player if the player stays in the range. Not only did I need to create the actual laser, but the particle system and finding the right balance.

This had to be the hardest part of this feature. Because I’ve never used a particle system before, it requires research on how to create it. To create one, it’s like any other game object:

Right clicking in the Hierarchy -> Effects -> Particle System

However, the issue is that the particles generated would shoot out from the origin, not sucked in. Luckily for me, this is easily achieved by rotating the particle system on the X axis and reverse the start speed.

Although easier to create than the particle system, there were some difficulty on the laser, the biggest one being how to damage the player if they’re inside the laser. Because the laser is practically the smaller laser but enlarged, if I was to use OnTrigger2DEnter, the player would be damaged once. This means if the player was still inside the laser, it would not deal any more damage.

In Unity, I can circumvent this issue by changing OnTrigger2DEnter to OnTrigger2DStay. Similar to OnTrigger2DEnter, OnTrigger2DStay would damage the player once they trigger the collider found on the big laser. However, if the player continues to stay inside the laser, it will continue to damage them, thus draining their health very quickly.