Creating a Boss Enemy — Part 3, Asteroid Belt Shield

Our Big Bad Boss can move, shoot fireballs and Freeze asteroids, but now it needs some sort of defense. If we could just shoot the Boss, it would be too easy for the Player. With this shield, the Player has to waste precious ammo to break down the Boss’s shield to damage them.

For my Boss, I decided to create a Freeze Asteroid Belt that would revolve around the Boss acting as a shield, but also created an animation where the Asteroid Belt expands, creating a kind of defensive attack!

Fancy shield!

Creating the Asteroid Belt

Creating the Asteroid Belt required some planning to fit 16 Freeze asteroids in a circle. The approach I decided to take was to use Unity’s Gizmos to visualize where to place the asteroids.

First create an Empty Game Object for your Parent Asteroid_Belt, and attach it as a child to the Boss. Make sure to place the transform near the center of the Boss’s body.

You could probably do this perfectly with code, however, I did not research that far — this approach made enough sense to me.

Now we need some variables inside our EnemyBoss script:

[SerializeField] so that we can tweak them in the Inspector and visualize the changes.

Then use Unity’s OnDrawGizmo() function:

The radius offset was added to get the circle as closest as possible to center of the Boss.

Which gives us this yellow circle where we can place our Freeze Asteroids around:

Doesn’t have to be perfect — They will be moving so the Player won’t notice something a little off

Rotate Around the Boss

For this, we’ll create a RotateAroundBoss script and attach it the Asteroid_Belt parent Game Object that holds all the asteroids.

It’s a very simple script that only requires two variables; a reference for the object to rotate around and the rotation speed.

The rest of the script is one line of code:

Asteroid Belt Expansion Animation/Attack

Now for the cool part, the Animation! This makes the Boss feel more alive, and much more complex!

Example of animation, without the rotation.

The animation is nothing fancy, just scaling the Asteroid_Belt parent up and back to it’s original position. But with the RotateAroundBoss script going as well, it looks much more complex.

To create this and incorporate it, we need to create an animation on the Asteroid_Belt parent object. This creates an Animator controller.

Head into the Animator window (while having Asteroid_Belt selected), and right-click and create an Empty State. Right click on the Empty state and make it the default state. It should turn Orange:

Then create a trigger parameter (on the Left of the Animator window) called AsteroidBeltExpansion. Make a transition TO our expansion animation (Blue highlighted above), and use this new parameter as a condition:

Create a new transition BACK to our Empty state. Then select the transition and make sure ‘Has Exit Time’ is selected:

Now we can jump back into the EnemyBoss script and create a new reference variable for our Animator:

And create a new Coroutine to constantly trigger the animation on a set period of time:

Which we can call during Start():

Now every 7.5 seconds, our Asteroid Belt will expand and contract once!

If all went well, you should have a working Defensive attack that makes the Big Bad Boss more intimidating!

In the next article we’ll cover the final piece for our Boss — it’s health system and appearance!



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