Day 59: Boss Part 1

Tyler Smallwood
3 min readJul 17, 2021

--

Objective: Create a boss that moves and fires randomly.

Today will just be about the logic. I used Enums to control the state of the boss. We have Idle, Moving, Attacking, LaserAttack, and Dead. Idle is where the boss will take a second to decide the next move. Moving is where the boss is moving from spot to spot. Attacking is deciding weather to fire normal basic firing or depending if the boss is in rage mode scatterbomb. Laser attack is another attack but from the idle position. And Dead is for when the boss’s health is equal or less than zero.

We need to check to see what happens per state. In the Update function we will use a switch statement to figure out what the boss does.

If the currentstate is idle we will get a random number between 0 and 3 to decide what happens.

If the state is moving, it’ll check to see if the boss is in rage. If it is not raging it’ll get a random number between 0 and 1 and decide if going left or right. If the boss is raging we will do the rage movement. The movements are done with animations, which we'll discuss tomorrow.

In Attacking state we will check again to see if the boss is in rage mode or not. If it is not do Basic attack and if it is do Scatter bomb.

LaserAttack state just calls the trigger in the animator. And Dead state just stops all the other states for working while the boss explodes.

The boss does need to get damaged, so we got a Damage function that takes in a int for the amount of damage.

We call the Damage function in OnTriggerEnter2D section. Depending on what the collision hit will decide the amount of damage caused to the boss.

We will allow a designer to change the amount of damage!

Tomorrow we will discuss other functions that we created to use with the animations to help control the states. Thank you for reading! Have a wonderful day!

--

--

Tyler Smallwood
Tyler Smallwood

Written by Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer

No responses yet