Geek Culture
Published in

Geek Culture

Creating a Boss Enemy — Part 4, Health System

Our Boss now has all the necessary things to make it a formidable opponent, but as of now, it’s invincible!

In this article, we’ll create a Health system for our Boss, and a unique explosion that triggers when you defeat it!

Disregard the “Wave 1”, haha.

Boss Health Bar UI

Creating the Boss Health bar is very similar to when we created the Player Thruster UI element. You can read up on that here:

First we’ll create the UI Elements needed inside our Canvas; a Border, a Fill, and Text to tell the Player who’s Health Bar it is:

I’ve nested these element into a Parent Object to make enabling/disabling them in the future much easier!

Now we can jump into our UIManager script attached to our Canvas UI. We’ll need to make two reference variables; one for the Boss fill to update the actual Health Bar, and another to enable/disable the entire Boss Health Info:

And utilize these variables in two new functions:

Boss Health in the Boss script

Let’s jump back to our EnemyBoss script to complete our Health Bar logic.

First we’ll get a reference to our UIManager and initialize at Start():

Now we can create our Global variables for the Boss Health:

Next we’ll create a function to call when the Boss will spawn that will enable the Boss Health Info UI objects, as well as set our Boss Health to full:

Then we can create our OnTriggerEnter2D logic. Each time the Boss gets damaged, we’ll decrease their health and update the UI:

For information on the Camera Shake effect (_player.CameraShake() ), see this article:

Finally, we’ll create a function that checks if the Boss Health is at zero. This will be called in Update(), and if called will cause an explosion sequence, disable the Boss Health Info UI elements, and start the process to begin the next wave of Enemies.

  • You could also end the game after you destroy the Boss if that’s what you fancy

Explosion Sequence

For the explosion sequence when the Boss gets destroyed, I reused the previous explosion VFX we created for the Asteroid. I also Instantiate 3 of those explosions, changing the colour, scale, and position for each one to give the explosion some depth!

Make sure to get a reference to link in the Inspector

Then the ExplosionSequence():

See top GIF for example!

When to Spawn the Boss

This is completely up to you when you want to spawn in the Boss. You could do it every 5 waves, only once and continue playing (like I did), or as the last Wave before “Winning” the game.

Handling your Boss Spawn will be done in the SpawnManager script:

Don’t forget to create a reference to the Boss prefab and link in the Inspector

For me, I arbitrarily chose to spawn the Boss after wave 7. After play testing my game, this seemed like a level of exhaustion where a Player would not be expecting a Boss to pop up. I like that essence of spontaneity.

And now, the Boss is finished! Adding a ‘Boss Enemy’ into your game is a great way to make it more memorable and add to the difficulty.

With our Game essentially finished, the last step is to build the game and show it off to the world! In the next, and last article of this series, we’ll cover those basics, and where to host your game!




A new tech publication by Start it up (

Recommended from Medium

Bootstrapping Kubernetes in an Offline/Air Gapped VM Cluster.

Latest capabilities in Dynamics 365 Project Operations

goalteryx is now beta

Where I’m Hunting for Enterprise Infrastructure Startups in 2020

The MVC Framework


#1. Version Control with Git

101 Tips For Being A Great Programmer (& Human)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Frank Warman

Frank Warman

Audio Engineer turned Unity Game Dev. Will be combining both my skillsets when appropriate, and will be documenting my Unity Dev growth in these Medium Articles

More from Medium

Saving Data in Unity3D Using Files

How to format a double value according to culture-specific formatting in Unity C#

Masked logging system in Unity

Mapping input to a player object.