Welcome back my fellow game developers to
a brand new video in brand new section.
And one of the better sections,
I will introduce you to the bus Skelly boss.
I'm not going to waste your time too much.
First of all, we will talk about the state machine,
what it is, how it is,
why we are using it,
how we are going to be using it,
using the animator, all of that good stuff.
And in the second part of the video,
we will be talking about the animations that I've
created just to guide you through the process.
If you have created the animations,
the middle, we will have a challenge.
If you already did all of the animations,
you can skip the second part.
Or if you think that you need a bit of help,
I just guide you through a little bit of what I did.
So with that out of the way,
let's not waste any more time.
Then let's get started with the boss fight 0 case.
So, uh, welcome to one of
the most exciting parts of
this entire project and that is the most battle.
What gain is complete without a loss button? No game.
So let's go ahead and think of how we're going
to create a boss battle.
First of all, let's talk about something
called the state machine.
If we look here in the animator,
you'll notice, and let's
take the doom player for example.
You'll notice that these are in fact animations,
but they also work as states.
So we have the states,
or I'm in the state of
the player ID links or player either name.
He's an estate.
He can do specific things.
He cannot move.
For example, he can shoot,
he can do a lot of stuff,
but he is in a state of idling.
Then we have the walking state
and then we have the player dashing.
So for example, when we are dashing,
we have certain animations.
Also cannot move.
I mean, sorry, we cannot shoot with our guns or weapons.
So that is a sign of a different state
where we have
different mechanics and different behaviors.
So we are going to use
the animator to produce these kinds of states.
And I was the whole time calling these animations.
But a lot of people like to call them states.
And that is okay.
You can call them whatever you want as long as it's
properly describes what is happening.
So let's talk more about states and what a state machine,
as a state machine is a behavioral model.
It consists of a finite number of states.
So behavior model, just like we have the idling,
just like we have the plane,
sorry, the running and the dashing.
These are behavioral models and they are finite.
So we always need to know how many states we have.
And a given input the machine performs
state transition and produces outputs.
So just like we have
the transitions between the animations in the animator,
so does a state machine have transitions?
So that's why the animator is the perfect,
Let's say tool to create this state machine.
So let's talk about what we have in our states.
First of all, we have the starting state.
So we have the starting state,
we transition into another state
which is the a or whatever it is.
Maybe we start by idling,
then we transition to walking,
then we can transition between,
for example, and this is all an example
between two states, B and C.
And for example, when we go from state a to state C,
we cannot go back to state a,
bot from state C,
we can go to state B,
go to state a, and then back and forth between a and b.
So this is just an example of what a state could be.
And obviously on each and
every transition, we have conditions.
So certain conditions have to be met in
order to transition from one state to another.
And this is something that we've been
doing all the time and the scores.
So I'm just going to continue on.
Let's talk about the boss state machine
that we are going to have.
So the first state will be the appearing.
So the boss, as soon as we enter the boss room,
the boss will start appearing from the ground
and you'll see the boss sprites in just a bit.
I provided you with them in the resources.
Then we start walking.
So as soon as the boss comes life,
then he will start walking towards the player.
So no time to lose,
no idling, no nothing.
The boss just start walking towards the player.
Then we have the five shots.
So we will give the ability to
our a huge skeleton boss that you'll see in
just a bit to fire certain shots adder.
So just like we had the enemy bullets,
just like we had the player bullets,
we will also have
the boss bullets that will be fired from many directions.
Then we will have
the melee attacks or just as I promised you,
we are going to create a melee attacks for our
Boss that will attack the player once he is near here.
So we will have some kind of timer.
And obviously we want to
have the transition go both ways.
So for example, we don't want to appear,
walk and then appear again. So that's it.
Once we appear, we never go back to
the state under a certain condition. We start walking.
Under a certain condition,
we start firing shots and then we start walking again.
And under certain conditions,
we also start melee attacking,
and under certain conditions we go back to walking.
But then there is the second part of the fight.
And that is when our enemy gets angry or our boss gets
angry when we shoot him enough that his health goes down.
He then starts walking angry.
He starts firing shots angry.
He starts angularly, mainly attacking us.
He will change colors,
you will change sizes.
And finally, when we kill him, if we kill him,
if we manage to do so,
we have the state of
dying where he cannot hurt us anymore.
He disappears and we went.
So I'm going to,
if you want, you can pause the video,
look at this, take this end.
We are going to be doing all of
these in our upcoming videos,
but I'm going to give you also a challenge to
create all the animations and think so,
create the animations that we'll have for the boss.
And let me just show you the resources.
We have the appear,
the attack, the dye,
the idle, the walk.
And if you're not sure what the Angry will be all
show you briefly after I've finished all the animations,
I won't be doing them live
because honestly it will take a lot of time.
It will take a lot of effort.
I will just create a new scene,
put the bars there,
and create the couple of animations.
Then you will need to create the appear, attack, walk,
shoot, getting angry, angry,
attack angry, shoot angry, walk.
And now if you're not sure how to create the angry,
just at least the angry walk,
for example, is the same as the angry shoot, sorry.
I mean, the angry walk is just the
same as the regular walk.
But what I'll do is I'll increase
the scale of the enemy, of the boss.
And I'll also make him a bit
of a red color so he looks different.
The angry attack is just the same as the attack.
And finally, we want to set the angry state,
that the angry state
will just have the boss as red color,
a bit bigger and scale and a bit faster animations also.
So with that out of the way,
pause the video right now, and I don't know,
Maybe I'll show you in the next video the animations.
Maybe I'll show you on this one the animations just
so he can see everything, set up everything.
And I'll see you in the next month maybe maybe, you know.
Hey, welcome back.
So how did you get on with that?
I just wanted to show you a couple of things or
the way I created my states and
how I made the angry walking and angry shooting and
angry attack and how I did the
getting angry may be you can be inspired.
I also fixed a couple of things.
If you did the attack,
you might have noticed that
the sprite moves to the right,
which is not very nice.
So I also fix that.
So let me show you what I did.
First of all, I got all of my sprites in here,
the Bible attack the idle we don't use.
So you can see the walking.
All of them were kept almost the same.
I just changed the filter and
make the pixels per unit 75.
And what did I do, this Kelly boss.
So let me show you what I did in here.
So let's say we are in the appearing.
Let me show you the appear.
Very simple, very normal.
Just there you go.
You can see that we have the skeleton appearing.
You can see I've added two box colliders.
One of them is a trigger so we can walk as you know,
where we walked through the walls.
Had me see. Okay.
So the one on the bottom,
the one at the top,
which is this one.
There we go. I can turn it off and on.
And you can see that's the one that we're going to
make a trigger that's just so we can hit the enemy,
but at the same time the enemy can stand
behind the background right here.
So there we go.
We have the appearing, as you can see.
And this structure here in the animator.
I didn't create the transitions yet
because I want to make them as we create the code.
I didn't want to do them without you
knowing because at some point we will have exit time,
we will have transition time
and all of these good things.
So as you can see, we start with
appearing just like we did in
the slides than walking
and between the walking and shooting,
then we get angry than the angry walking,
angry attack and angry shooting.
So the visit the walking.
There we go. Very simple.
We just walk around.
Then we have the attack.
So as you can see, maybe in
your case and even in mind still,
you can see that the boss
just moves a little bit so to the,
upwards and to the right.
So notice there we go.
You can see that he moved just a little bit,
but that's even though we changed a bit in the sprites.
If you kept them the same,
you'll notice that yours moves a lot.
So to fix this,
I've made sure to go into the Sprite Editor.
And in here I changed the custom pivot.
So this is the point where let's call it the center.
It's a pivot actually.
But there is a slight difference
between pivot and center,
but this is the center right
now when the center was right here,
because the whole image was moved to the right.
That's why the entire enemy moves to the right.
So what I did is I changed the center right here,
created a custom pivot and it was 0.6554878.
If you want to copy this number just like I did,
or maybe you can find one that is better.
Mind isn't perfect.
As you can see, he moves a little bit to the right.
So you can find your own value and you can see
that you don't have to go and edit all the sprites.
You just can select all of them.
And in here, you can select the custom pivot on
the bottom and then write
down this number, keep it at 0.5.
This on the Y, on the x,
change it to 6554878.
Okay, and what else did we do?
So this is the attack and you can see that I leave
a bit of room when he is striking.
So we will have an attack on this side.
And once the sort is APU,
wait a little bit just to give room to
our player to maybe runaway.
And then we swing back down.
And when we are going to be creating are mainly attack.
You'll see how this is crucial
because we will add events systems that will
damaged the player only
when the salt is at a certain position.
We don't want to damage the player when soldiers up
because obviously the skeleton isn't swinging.
So we'll just damaged him when the source is right
here and we'll create some kind of
circular collider right here.
And if the player is inside,
then he gets damaged.
That's how we will create the Malay attack.
So what else do we owe to the shooting?
So I've got this one from the dying sprites, I believe.
Yes, there we go.
So it's from the dying sprites
and it's not the smartest thing in the world.
I just need some particular sprite.
And as you can see when we are shooting,
just change the scale.
The scale increases and then goes back down.
You can see it right here.
So I send the record button and then made them bigger,
smaller, bigger, smaller, bigger, smaller.
And this is when we will be shooting.
We will add, just like we did with an irregular.
And it means we will add points of shooting,
so we will add four.
And then when he is angry,
we will add six and talking about angry.
Let's see how we get angry.
So there we go.
You can see this is how we get angry.
We first of all, we become bigger.
So we have the smaller, bigger, smaller, bigger.
And I also added the idle sprites in here.
You don't have to. I didn't notice much change.
If we delete all the legal sprites,
nothing changes honestly,
but I just wanted to have something
different than just a stale image.
This adds, maybe in
just a little subtle movement
to the player that with the enemy,
I mean to the boss, to Skelly,
you can see that he gets bigger,
smaller, bigger, smaller,
and his hand twitches just a little bit enough to just
have a little bit of
life and him growing bigger or smaller.
And then you can see he becomes
big where we have the scale
at 1.3 on the x and on the y,
obviously on the SAT, we don't need it.
And then we just wait a couple of seconds for
the player to realize what just happened.
And then finally we start walking angry.
So whereas the walking angry or angry walking,
it's the exact same as the regular walking,
but it's a bit faster.
And on the first frame,
I made sure to set the scale at 1.3.
So in the animation, I had the record.
I change the color to complete red.
Oh, and by the way in here,
whereas the getting angry.
So they get angry, you'll notice that he becomes
slowly read read her.
And on here, this is where I
set it to red and it slowly moves.
You can see the color right here.
It slowly moves to read.
On the angry walking,
we just set it to read at the beginning,
increase the scale to 1.3 on all sides and
we make the walking a little bit faster.
This is what will happen when he gets angry.
He will start walking faster,
so the animations will be faster.
We have the angry shooting,
so exactly the same,
the color it just changes.
It's completely rad because at this point
the whole NME or bosses red.
And finally the angry attack.
It's exactly the same,
just with a bigger scale,
a different color, and much faster movements.
So you can see there is
no waiting time when the sources up,
he just keeps chopping away all the time and we will
create the same thing we will have in here, the damage.
This position we will have the damage.
And at this position we will also have the damage.
Okay, so with that out of the way,
I hope you enjoyed this video.
I hope you created all of your animations.
It took the time to do them.
That's stage all of our whoa, that's nice.
Anyways, for some reason I have an error.
I will fix that later on.
But for now, I hope you enjoy it and I'll see you in
the next video where we will be actually
moving our enemy and destroying things.
So see you then.