1
00:00:03,050 --> 00:00:07,340
In this lecture, we're saving up our animations so that when the player runs up a ladder or down a

2
00:00:07,340 --> 00:00:08,990
ladder, we play the ladder animation.

3
00:00:08,990 --> 00:00:12,680
But if you just chilling out and hang it on the ladder will play the idle animation.

4
00:00:12,680 --> 00:00:17,510
And we'll also make sure the player can just drop off the letter and be able to run around still.

5
00:00:17,540 --> 00:00:23,060
We've already set up our climbing animation state and we have our is climbing condition in here.

6
00:00:23,060 --> 00:00:29,240
So I'm going to give this to you as another big not many hints type of challenge to set up the climbing

7
00:00:29,240 --> 00:00:32,780
animation so that it plays when the player climbs the ladder.

8
00:00:32,780 --> 00:00:36,710
If the player is stationary on the ladder, the climbing animation should not play.

9
00:00:36,710 --> 00:00:38,300
So it shouldn't look like you're trying to climb.

10
00:00:38,300 --> 00:00:39,320
If you're standing still.

11
00:00:39,350 --> 00:00:43,370
I think it's okay just to have the character idling that says, Hey, you can jump off the ladder or

12
00:00:43,370 --> 00:00:44,900
walk off the ladder if you want.

13
00:00:44,900 --> 00:00:46,070
So good luck with that.

14
00:00:46,070 --> 00:00:47,690
That's all I'm going to give you for this challenge.

15
00:00:47,690 --> 00:00:48,380
Pause the video.

16
00:00:48,380 --> 00:00:50,300
Take that on so you back in when you're done.

17
00:00:52,430 --> 00:00:58,550
Now over into our scripting here, I'm going to look under climb ladder and first thing I'm going to

18
00:00:58,550 --> 00:01:03,500
do is jump down underneath where we were previously playing around with the gravity scale in here,

19
00:01:03,500 --> 00:01:10,130
I'm going to say we're currently climbing, so therefore we wish to change the animation and that's

20
00:01:10,610 --> 00:01:15,170
through saying my animator dot set bull because we're using a bull in here.

21
00:01:15,170 --> 00:01:18,560
You're climbing or you're not climbing and it will be climbing.

22
00:01:18,560 --> 00:01:20,630
Make sure you get this exactly right.

23
00:01:20,630 --> 00:01:22,880
It's always worthwhile to jump back into here.

24
00:01:22,880 --> 00:01:24,680
Oh, and I might have messed that up, actually.

25
00:01:24,680 --> 00:01:27,800
Copy is climbing back into our script.

26
00:01:27,800 --> 00:01:28,820
It's not climbing.

27
00:01:28,820 --> 00:01:30,110
It's is climbing.

28
00:01:30,230 --> 00:01:34,670
Climbing is the state is climbing is the particular ball that we're setting.

29
00:01:34,670 --> 00:01:39,560
So it is climbing and then comma will make this true just to do this as a quick way.

30
00:01:39,560 --> 00:01:41,810
And then we're going to improve this as time goes on.

31
00:01:41,810 --> 00:01:47,540
So if you're on the ladder, set your climbing to try to save that back over into unity.

32
00:01:47,540 --> 00:01:49,100
We'll see how we go with that step.

33
00:01:49,100 --> 00:01:50,750
I like to do things in small steps.

34
00:01:50,750 --> 00:01:51,470
Did that work?

35
00:01:51,470 --> 00:01:52,490
Did that work okay?

36
00:01:52,520 --> 00:01:53,380
That worked all up.

37
00:01:53,450 --> 00:01:54,080
It didn't work.

38
00:01:54,080 --> 00:01:54,890
So you know what?

39
00:01:54,890 --> 00:01:56,620
Step and the process is not working.

40
00:01:56,630 --> 00:01:57,260
Run, run, run.

41
00:01:57,260 --> 00:01:57,950
Touching the ladder.

42
00:01:57,950 --> 00:02:02,450
And as soon as I touch it, he looks like he wants to climb and now he's climbing forever.

43
00:02:02,450 --> 00:02:02,900
So it's great.

44
00:02:02,900 --> 00:02:04,070
We've got the first part of that.

45
00:02:04,070 --> 00:02:09,380
But we do have an issue in here, which means when you're not climbing the ladder, we need to set this

46
00:02:09,380 --> 00:02:14,930
back to false so that right below our gravity stuff, I'm going to you know what?

47
00:02:14,960 --> 00:02:17,060
I'll go down here and copy this exact line.

48
00:02:17,060 --> 00:02:21,530
My animator dot set ball is climbing will be false.

49
00:02:21,530 --> 00:02:25,280
We don't want to be doing climbing if we are currently not climbing, save that up.

50
00:02:25,400 --> 00:02:28,580
Well, currently not touching the ladder is our criteria in there.

51
00:02:28,580 --> 00:02:31,820
So we'll click on save and then play.

52
00:02:32,450 --> 00:02:35,810
Run, run, run, run, run, run, up, up, up, down too down.

53
00:02:35,810 --> 00:02:39,380
When I'm no longer touching the ladder, I'm no longer doing my ladder animation.

54
00:02:39,380 --> 00:02:40,580
I think that's cool.

55
00:02:40,580 --> 00:02:43,760
Now the problem we've got is that if I'm just sort of standing there, I'm doing this.

56
00:02:43,790 --> 00:02:47,420
We, we, we, we look like I'm trying to climb up the ladder and I'm not moving, so it doesn't make

57
00:02:47,420 --> 00:02:47,930
sense.

58
00:02:47,930 --> 00:02:51,770
I'd rather have the character play the idol because I can still move left and right, which is an okay

59
00:02:51,770 --> 00:02:52,250
behavior.

60
00:02:52,250 --> 00:02:52,970
I want that.

61
00:02:52,970 --> 00:02:56,210
I don't want to have a fixed no movement climbing.

62
00:02:56,210 --> 00:03:01,730
So if climbing was just one frame of climbing, then it would look like we're still climbing on the

63
00:03:01,730 --> 00:03:02,120
ladder.

64
00:03:02,120 --> 00:03:04,400
But if I move left and right, it look a little bit silly.

65
00:03:04,400 --> 00:03:06,170
You might want to have that behavior in your game.

66
00:03:06,290 --> 00:03:07,940
If you're on the ladder, you're locked on the ladder.

67
00:03:07,940 --> 00:03:09,020
You can't move left or right.

68
00:03:09,020 --> 00:03:11,240
You can't jump up and down until you get to the top.

69
00:03:11,240 --> 00:03:15,350
But for me, I want to be able to say you can come and go off ladders, so therefore I want to transition

70
00:03:15,350 --> 00:03:20,540
back into idle if we've stopped moving the way we do that back in here, we've played around with this

71
00:03:20,540 --> 00:03:21,200
already.

72
00:03:21,200 --> 00:03:27,050
Having movement velocity in here player has horizontal speed if this is true.

73
00:03:27,050 --> 00:03:28,700
So I'm going to copy all of that.

74
00:03:28,700 --> 00:03:36,200
So ball player has horizontal speed, equals math abs, etc. jump down into our climb ladder.

75
00:03:36,200 --> 00:03:38,180
Right above setting is climbing.

76
00:03:38,210 --> 00:03:45,350
True, I'm going to paste this in instead of player has horizontal speed to be player has vertical speed

77
00:03:45,350 --> 00:03:53,840
and the math f grabs my rigid body vol velocity dot y is greater than math f epsilon.

78
00:03:53,840 --> 00:03:59,480
So if we've got any sort of up and down velocity, then it's going to be greater than zero or math f

79
00:03:59,780 --> 00:04:01,340
epsilon that would be a ball.

80
00:04:01,340 --> 00:04:08,180
So instead of setting is climbing true will set is climbing is based upon whatever our player has vertical

81
00:04:08,180 --> 00:04:09,440
speed resolves to.

82
00:04:09,440 --> 00:04:11,150
If that's true, then this will be true.

83
00:04:11,150 --> 00:04:13,340
If that's false, then this will be false.

84
00:04:13,340 --> 00:04:17,930
We can leave this one up at the top here is false because we want to be saying it's just false.

85
00:04:17,930 --> 00:04:23,690
If you're not touching the ladder, we don't need to say the player has vertical speed is our bull condition

86
00:04:23,690 --> 00:04:24,410
up there.

87
00:04:24,410 --> 00:04:27,170
So let's save, see how we go with all of that.

88
00:04:27,410 --> 00:04:29,240
Click on our play button.

89
00:04:31,980 --> 00:04:34,550
One over two al letter touching the letter.

90
00:04:34,560 --> 00:04:36,540
But while still on the ground, nothing happening.

91
00:04:36,540 --> 00:04:36,930
That's good.

92
00:04:36,930 --> 00:04:38,600
That's what I want as I climb up.

93
00:04:38,610 --> 00:04:41,430
If I'm climbing up and down, then we see the letter animation.

94
00:04:41,430 --> 00:04:46,560
And if I stop, I see my idol and I like that that says, Hey, I can now go jumping over there.

95
00:04:46,570 --> 00:04:47,580
Okay, that's all good.

96
00:04:47,580 --> 00:04:50,550
We can't jump off the ladder because we're currently not touching the ground.

97
00:04:50,550 --> 00:04:51,120
That's okay.

98
00:04:51,120 --> 00:04:53,970
I don't think I want the player to be trying to do that sort of jump.

99
00:04:53,970 --> 00:04:57,150
I know that if you're on the ladder, you can drop off the ladder, which is kind of neat.

100
00:04:57,150 --> 00:04:58,560
Do we jump off it?

101
00:04:58,560 --> 00:05:01,380
But you can't actually jump off the ladder.

102
00:05:02,310 --> 00:05:03,000
Yeah, that's cool.

103
00:05:03,000 --> 00:05:04,050
I'm happy with that behavior.

104
00:05:04,050 --> 00:05:07,410
If you wanted the player to be able to jump off the ladder, then you need to be able to say that it's

105
00:05:07,410 --> 00:05:11,640
not just the ground that's the determinant of jumping, it's also whether you're on a ladder.

106
00:05:11,640 --> 00:05:15,210
But I'm happy with that and I'm happy with how our game is coming along.

107
00:05:15,210 --> 00:05:15,840
So good stuff.

108
00:05:15,840 --> 00:05:17,040
I'll see you in the next lecture.

