In this lecture, we're saving up our animations so that when the player runs up a ladder or down a
ladder, we play the ladder animation.
But if you just chilling out and hang it on the ladder will play the idle animation.
And we'll also make sure the player can just drop off the letter and be able to run around still.
We've already set up our climbing animation state and we have our is climbing condition in here.
So I'm going to give this to you as another big not many hints type of challenge to set up the climbing
animation so that it plays when the player climbs the ladder.
If the player is stationary on the ladder, the climbing animation should not play.
So it shouldn't look like you're trying to climb.
If you're standing still.
I think it's okay just to have the character idling that says, Hey, you can jump off the ladder or
walk off the ladder if you want.
So good luck with that.
That's all I'm going to give you for this challenge.
Pause the video.
Take that on so you back in when you're done.
Now over into our scripting here, I'm going to look under climb ladder and first thing I'm going to
do is jump down underneath where we were previously playing around with the gravity scale in here,
I'm going to say we're currently climbing, so therefore we wish to change the animation and that's
through saying my animator dot set bull because we're using a bull in here.
You're climbing or you're not climbing and it will be climbing.
Make sure you get this exactly right.
It's always worthwhile to jump back into here.
Oh, and I might have messed that up, actually.
Copy is climbing back into our script.
It's not climbing.
It's is climbing.
Climbing is the state is climbing is the particular ball that we're setting.
So it is climbing and then comma will make this true just to do this as a quick way.
And then we're going to improve this as time goes on.
So if you're on the ladder, set your climbing to try to save that back over into unity.
We'll see how we go with that step.
I like to do things in small steps.
Did that work?
Did that work okay?
That worked all up.
It didn't work.
So you know what?
Step and the process is not working.
Run, run, run.
Touching the ladder.
And as soon as I touch it, he looks like he wants to climb and now he's climbing forever.
So it's great.
We've got the first part of that.
But we do have an issue in here, which means when you're not climbing the ladder, we need to set this
back to false so that right below our gravity stuff, I'm going to you know what?
I'll go down here and copy this exact line.
My animator dot set ball is climbing will be false.
We don't want to be doing climbing if we are currently not climbing, save that up.
Well, currently not touching the ladder is our criteria in there.
So we'll click on save and then play.
Run, run, run, run, run, run, up, up, up, down too down.
When I'm no longer touching the ladder, I'm no longer doing my ladder animation.
I think that's cool.
Now the problem we've got is that if I'm just sort of standing there, I'm doing this.
We, we, we, we look like I'm trying to climb up the ladder and I'm not moving, so it doesn't make
sense.
I'd rather have the character play the idol because I can still move left and right, which is an okay
behavior.
I want that.
I don't want to have a fixed no movement climbing.
So if climbing was just one frame of climbing, then it would look like we're still climbing on the
ladder.
But if I move left and right, it look a little bit silly.
You might want to have that behavior in your game.
If you're on the ladder, you're locked on the ladder.
You can't move left or right.
You can't jump up and down until you get to the top.
But for me, I want to be able to say you can come and go off ladders, so therefore I want to transition
back into idle if we've stopped moving the way we do that back in here, we've played around with this
already.
Having movement velocity in here player has horizontal speed if this is true.
So I'm going to copy all of that.
So ball player has horizontal speed, equals math abs, etc. jump down into our climb ladder.
Right above setting is climbing.
True, I'm going to paste this in instead of player has horizontal speed to be player has vertical speed
and the math f grabs my rigid body vol velocity dot y is greater than math f epsilon.
So if we've got any sort of up and down velocity, then it's going to be greater than zero or math f
epsilon that would be a ball.
So instead of setting is climbing true will set is climbing is based upon whatever our player has vertical
speed resolves to.
If that's true, then this will be true.
If that's false, then this will be false.
We can leave this one up at the top here is false because we want to be saying it's just false.
If you're not touching the ladder, we don't need to say the player has vertical speed is our bull condition
up there.
So let's save, see how we go with all of that.
Click on our play button.
One over two al letter touching the letter.
But while still on the ground, nothing happening.
That's good.
That's what I want as I climb up.
If I'm climbing up and down, then we see the letter animation.
And if I stop, I see my idol and I like that that says, Hey, I can now go jumping over there.
Okay, that's all good.
We can't jump off the ladder because we're currently not touching the ground.
That's okay.
I don't think I want the player to be trying to do that sort of jump.
I know that if you're on the ladder, you can drop off the ladder, which is kind of neat.
Do we jump off it?
But you can't actually jump off the ladder.
Yeah, that's cool.
I'm happy with that behavior.
If you wanted the player to be able to jump off the ladder, then you need to be able to say that it's
not just the ground that's the determinant of jumping, it's also whether you're on a ladder.
But I'm happy with that and I'm happy with how our game is coming along.
So good stuff.
I'll see you in the next lecture.