Hello again.
In this lecture, we're setting up some more states so our player can run when we're in that state and
our player can climb when the player is in that state.
Let's get started.
Let's start by having a look at our sprite sheet.
You see, if I click on the sprite sheet and then click on Sprite editor, it will zoom in and allow
me to see what's going on.
If we click on this bottom left here, I believe this is going to be our run animation along the bottom
here.
Run, run, run, run.
Yet with a little bit of a bubble as he goes.
And this is from number 19.
So Frame 19 or Sprite 19, all the way up to Sprite 28, close out of our Sprite editor, find our Sprite
sheet, open that up and then look down for let's see where is 19 over on the right hand side here.
I've got my preview so I can see the number that's going to be 18, 19 from there.
So find 19, scroll all the way down the end of our player sprite highlight by holding shift and then
left click then I'll right click create animation.
This animation I'll call running because that's what we're doing.
We are running in that animation and to pop that into the animation folder, open up the animation folder.
Now drag running into our animated controller and we have running in there.
It doesn't matter where you put these things, it's all just representational, it doesn't matter the
exact layout, but I'm going to put my running just there underneath my idle.
Now we need to tell our system when to go from idle to running, and we need to give it a transition.
And a transition says this is you transitioning from one state to another.
So if you click on idle with your left click and then right click Make Transition, it brings up our
little arrow key thing here.
Drag that over the top of running and it will snap.
Click to pop it on top of running.
Now if you click on the arrow itself, you get some additional information we've got in here.
I'm going to push the preview down.
I've got in here a little bit of blending.
That means the blend from one animation to another.
We don't need to do that because when the player pushes an arrow key, we want them to we want our character
to respond immediately and do the run animation, not to have a little bit of I'm still idling for a
while and that's what's happening here, idling from one state to another.
So I'm going to open up settings and just put the transition duration down to zero.
I'm also going to put the exit time down to zero.
And while we're here, I'm going to turn off has exit time.
What does has exit time mean?
Well, normally we would use that if we wanted to trigger a one shot animation.
Say you push the button in, the player did a little jump for joy and then returned.
And after that animation had finished playing, it just went back to idle.
Then you can say has exit time, which is basically a cool way of us saying Play the entire animation
and then just go back to where you came or finish doing the animation.
We're done.
We're not going to use that because we want to say, if you're holding down the controller, keep running
and keep running.
Keep running.
If you're standing on a ladder, then stay in the ladder animation.
If you're standing on the spot, just do idle.
So we're going to turn off has exit time.
And you see when we do that, it says we've got a little warning.
Transition needs at least one condition.
We don't have a condition at the moment.
So let's make a condition that says, well, when is it that you transition from idle to running?
So if you click on your animator window, it's probably by default on the Layers tab.
There's another tab here parameters when you click the plus button and then we've got a few options
here for the type of parameter that we'll use as a condition we're going to select ball.
Ball is going to be true or false.
So we're going to call this is running because is running is either true.
That means you're running or it's false.
That means you're not running.
So it is running.
And then over in the conditions we'll click plus by default is running as populated in there and is
running is true.
That means if we're running, go into the running state.
Now I'm going to click on the running animation again, right click make transition back to Idle.
Actually, while I'm here, I'm going to click on Idle.
I'm going to change the name of this to idling because I'm idling, I'm running, I'm climbing.
So we'll use that naming convention in here.
It doesn't matter a great deal, but I like to have these things match up.
I'm going to click on this transition line, set my duration down to zero once again, exit time to
zero once again and turn off has exit time.
Click on the criteria here.
Just a little challenge for you.
What do we need to set this to?
Well, is running needs to be false.
The other thing I'll do while I'm here, click on running animation and we need to make sure we have
loop time.
So it loops over and over and over and doesn't just play one time.
Now if we click on play, that will take us to the game window.
I'm just going to click back on the scene window because I can zoom in a little bit closer.
It makes it easier to see what's going on.
And in our parameters, if I click this checkbox, we should go into our running animation and this
is what we'll be doing in code.
Now we can just click it manually, click it on and click it off, and that will change from one state
to another.
So it should change from running to idling.
When we're clicking on that, this is what we'll be doing in our code in upcoming lectures, which is
going to be really cool.
We can visualize it here.
Now if you find your running's a little bit slow, which I kind of am finding in here, then we can
hop out of play mode, we can go over to running animation, we can go to the running state and we can
change the speed to say, oh, 1.5, click on play.
I might be able to do that in play mode actually, and keep the changes.
Then click on just back to see it again.
Click on Running, Run, Run, Run, Run.
That seems like a little bit more of a brisk run, doesn't it?
That's pretty good.
If we change this.
Let me just do a little experiment while I'm in play mode.
Hop out of play mode.
It does retain that that change that we make, which is cool.
1.5 as you know, a lot of things don't retain, but this seems to be retained now.
Next up, we're going to implement our ladder climb.
So back over to our sprites will find our sprite sheet, click on Sprite editor, have a look at what's
going on.
It's going to be these two just here and they are 14 and 15 that will be implementing.
So it's frame 14 and 15 will be setting up.
And I want you to do this as a challenge to implement climbing animation state, create a transition
from idling to climbing that's important and create a trigger for the climbing state that we can test
it and go about do doing your testing.
So pause the video.
Take that on.
I'll see you back here when you're done.
Okay.
First step we'll go into.
I forgot the numbers I selected already on here.
It was 14 and 15, so we'll find 14 and 15.
I didn't do anything there.
14 and 15.
Sounded like I was in trouble.
Didn't I didn't do anything.
Don't make the change.
I like both of those.
Right click create animation.
We'll call this animation climbing or drag climbing over into animations from animation folder will
drag climbing into our animated controller.
Pop it over to the right here because I want this coming off idling as well.
We're going to go if we stop running then and we start climbing, we'll transition through idling.
To do that, we don't need to go directly from running to climbing.
It'll just be not running.
Okay.
AM climbing.
That's the logic I'm going to use here.
So right click make transition over to climbing while I'm here.
Right click may transition back to idling.
I'm going to create my parameter while I'm here, which will be a ball we'll call this is climbing now
we'll click on the from idle to climbing.
Change our settings in here down to zero down to zero.
Turn this guy down to zero.
Turn that guy off.
We'll add our condition which will be is climbing is true.
Yes.
Now on the way back again we will drop the transition doesn't have an exit time and we will click plus
and is climbing is false.
Okay.
Now I'm just going to click my running checkbox here, click on play to test out to see if climbing
works.
Not doing anything at the moment, just idling, hanging out chilling click on is climbing.
Okay, I forgot to do looping.
So click on our climbing animation.
Click on looping.
I think I've forgotten to do looping for every single animation I've done so far in this section of
the course.
Click on scene climbing.
Oh, that's really fast.
Maybe a little bit too fast.
So I'm just going to quickly turn the climbing down to say .8.75.
Maybe it's too fast because we've only got the two frames, so it's just flicking between those two.
That's fine.
And we need to have a way of saying, when you're stopped, stay in this state, but don't actually
play the animation.
We'll play around with that later on because we don't want a player stopped on the ladder and be like.
Da da da da da da like that.
We'll figure that out later on.
So now we've got our running state and our climbing state misbehaves a little bit if you click them
both at the same time.
But in our code logic, we won't let the player do that.
You'll be doing one or the other.
So there we go.
We've got some cool animation states that will allow us to have our character come to life when we actually
start moving it around on the screen.
So great work in this lecture.
I will see you in the next one.