Phase 2: Boss AI- Part 1

Dominique Dos Santos
Nerd For Tech
Published in
4 min readJul 3, 2021

In the final challenge of the course, we have to create a boss that you have to fight at the final wave. I mean what is a game without a hard boss to defeat right?

Create a final Wave that includes a boss at the end.
Moves down the screen to the centre and stays there.
Unique attacks towards the player.

I really didn’t know where to start with this challenge and therefore I decided to do a bit of research and Brackeys made a video on how to create a boss using something called Finite State Machines or FSM for short. If you’ve worked with animation in Unity before then you’ve already worked with FSM. Each animation is a separate state and with logic, you trigger those states. This gets a lot more complex when you start using blend trees but for the boss, we don’t need to get that complicated.

If you don’t know what FSM is I’ll quickly explain. Basically, FSM is a design pattern where automation comes into play. Commonly used in AI implementations for certain behaviours. Using FSM you can create complex AI for NPC’s Enemies and Bosses. And in this case, I’ll be using FSM to create the various states, animations and actions for our boss.

In this article, I’ll explain the states that my boss will have and in the next article(s) I’ll be implementing these states in a (hopefully) easy to understand manner.

Boss FSM States

The art assets for this project that got included a boss with various animation sprites included. And to keep things simplified I’ll be using those animations as the basis for each state. The boss has idle, move, die and four attack animations. I’ve created a damage animation from the die animation. I’ve just used the first few sprites to create this animation. At this point, we have 8 base animation states to use.

In the above diagram, I’ve planned out the various states and I’ll be explaining each one.

The entry state is the state in which the boss enters the game. During this state, the boss will move down the screen to a point and then transition to the Idle state. While the boss is entering the game he will be invulnerable to attack. In the Idle state, the boss will decide what he will do next, he will either move or attack. If the boss decides to move he will become invulnerable again and move to one of three predefined positions. Once the position is reached then the boss will become vulnerable again. If the player damages the boss during the first stage of the boss he will immediately attack back. The boss will start with 50 health and when about half of the HP is lost the boss will become enraged.

During the enraged state, the boss will become invulnerable again and at the end of the state the boss will become vulnerable again but this time he will have more attacks to use and he will move around much faster and decide much faster.

Planned Weapons

The challenge requires this boss to have unique attacks and since we have four different attacks I decided to reuse the enemy laser for the Attack 1 state. Attack 2will also shoot lasers but more aggressively and Attack 3 will also reuse the enemy missiles and shoot those. For the last attack, I’ll create a new weapon type. I really liked the idea of a large phaser or laser beam that would shoot straight down the screen and potentially damage the player.

I found it a good idea to reuse some of the weapons the enemies have to retain consistency through the level and different waves. The different enemies have some variation but still look more or less the same and the same is true for the boss and makes sense to me to have some of the same behaviour or mechanics.

The last thing I wanted to do is create some win state, naturally, the best way to win the game is to defeat the boss but I liked the idea of dropping some item as a reward. I decided the boss will drop a star or trophy when he dies and the game will only end when the player collected this item. I wanted to end my game with a Star Wars-like scrolling text with some backstory as to why the player ended up shooting at enemies and defeat the boss. Although my game had no real story from the start I decided to end it with a small story.

I hope you’ll enjoy this journey of creating the final boss with me and I’ll do my best to explain everything as clear and easy to understand as possible. This will be the first boss I’ll be creating and I’m sure it will be a fun and rewarding experience.

--

--

Dominique Dos Santos
Nerd For Tech

Self-taught Unity and C# Developer with a passion for games and the stories they tell.