1
00:00:03,130 --> 00:00:03,610
Hello again.

2
00:00:03,610 --> 00:00:08,200
In this lecture, we're setting up some more states so our player can run when we're in that state and

3
00:00:08,200 --> 00:00:11,050
our player can climb when the player is in that state.

4
00:00:11,050 --> 00:00:12,130
Let's get started.

5
00:00:12,160 --> 00:00:13,780
Let's start by having a look at our sprite sheet.

6
00:00:13,790 --> 00:00:17,860
You see, if I click on the sprite sheet and then click on Sprite editor, it will zoom in and allow

7
00:00:17,860 --> 00:00:19,150
me to see what's going on.

8
00:00:19,150 --> 00:00:23,710
If we click on this bottom left here, I believe this is going to be our run animation along the bottom

9
00:00:23,710 --> 00:00:23,980
here.

10
00:00:23,980 --> 00:00:24,670
Run, run, run, run.

11
00:00:24,670 --> 00:00:26,860
Yet with a little bit of a bubble as he goes.

12
00:00:26,860 --> 00:00:29,260
And this is from number 19.

13
00:00:29,260 --> 00:00:36,490
So Frame 19 or Sprite 19, all the way up to Sprite 28, close out of our Sprite editor, find our Sprite

14
00:00:36,490 --> 00:00:41,530
sheet, open that up and then look down for let's see where is 19 over on the right hand side here.

15
00:00:41,530 --> 00:00:46,570
I've got my preview so I can see the number that's going to be 18, 19 from there.

16
00:00:46,570 --> 00:00:52,600
So find 19, scroll all the way down the end of our player sprite highlight by holding shift and then

17
00:00:52,660 --> 00:00:56,800
left click then I'll right click create animation.

18
00:00:56,800 --> 00:01:00,100
This animation I'll call running because that's what we're doing.

19
00:01:00,100 --> 00:01:05,319
We are running in that animation and to pop that into the animation folder, open up the animation folder.

20
00:01:05,319 --> 00:01:09,790
Now drag running into our animated controller and we have running in there.

21
00:01:09,790 --> 00:01:13,690
It doesn't matter where you put these things, it's all just representational, it doesn't matter the

22
00:01:13,690 --> 00:01:17,620
exact layout, but I'm going to put my running just there underneath my idle.

23
00:01:17,620 --> 00:01:24,370
Now we need to tell our system when to go from idle to running, and we need to give it a transition.

24
00:01:24,370 --> 00:01:28,330
And a transition says this is you transitioning from one state to another.

25
00:01:28,330 --> 00:01:32,470
So if you click on idle with your left click and then right click Make Transition, it brings up our

26
00:01:32,470 --> 00:01:33,700
little arrow key thing here.

27
00:01:33,730 --> 00:01:35,920
Drag that over the top of running and it will snap.

28
00:01:35,920 --> 00:01:38,260
Click to pop it on top of running.

29
00:01:38,260 --> 00:01:42,280
Now if you click on the arrow itself, you get some additional information we've got in here.

30
00:01:42,320 --> 00:01:44,170
I'm going to push the preview down.

31
00:01:44,200 --> 00:01:46,060
I've got in here a little bit of blending.

32
00:01:46,060 --> 00:01:48,400
That means the blend from one animation to another.

33
00:01:48,400 --> 00:01:53,380
We don't need to do that because when the player pushes an arrow key, we want them to we want our character

34
00:01:53,380 --> 00:01:58,060
to respond immediately and do the run animation, not to have a little bit of I'm still idling for a

35
00:01:58,060 --> 00:02:01,180
while and that's what's happening here, idling from one state to another.

36
00:02:01,180 --> 00:02:05,650
So I'm going to open up settings and just put the transition duration down to zero.

37
00:02:05,680 --> 00:02:07,660
I'm also going to put the exit time down to zero.

38
00:02:07,660 --> 00:02:10,750
And while we're here, I'm going to turn off has exit time.

39
00:02:10,750 --> 00:02:11,980
What does has exit time mean?

40
00:02:11,980 --> 00:02:15,940
Well, normally we would use that if we wanted to trigger a one shot animation.

41
00:02:15,940 --> 00:02:20,890
Say you push the button in, the player did a little jump for joy and then returned.

42
00:02:20,890 --> 00:02:24,640
And after that animation had finished playing, it just went back to idle.

43
00:02:24,640 --> 00:02:29,680
Then you can say has exit time, which is basically a cool way of us saying Play the entire animation

44
00:02:29,680 --> 00:02:32,950
and then just go back to where you came or finish doing the animation.

45
00:02:32,950 --> 00:02:33,580
We're done.

46
00:02:33,580 --> 00:02:37,450
We're not going to use that because we want to say, if you're holding down the controller, keep running

47
00:02:37,450 --> 00:02:37,890
and keep running.

48
00:02:37,900 --> 00:02:38,470
Keep running.

49
00:02:38,470 --> 00:02:41,710
If you're standing on a ladder, then stay in the ladder animation.

50
00:02:42,040 --> 00:02:44,110
If you're standing on the spot, just do idle.

51
00:02:44,110 --> 00:02:46,330
So we're going to turn off has exit time.

52
00:02:46,330 --> 00:02:48,700
And you see when we do that, it says we've got a little warning.

53
00:02:48,730 --> 00:02:50,890
Transition needs at least one condition.

54
00:02:50,890 --> 00:02:52,090
We don't have a condition at the moment.

55
00:02:52,090 --> 00:02:56,380
So let's make a condition that says, well, when is it that you transition from idle to running?

56
00:02:56,380 --> 00:03:00,460
So if you click on your animator window, it's probably by default on the Layers tab.

57
00:03:00,460 --> 00:03:04,900
There's another tab here parameters when you click the plus button and then we've got a few options

58
00:03:04,900 --> 00:03:09,610
here for the type of parameter that we'll use as a condition we're going to select ball.

59
00:03:09,610 --> 00:03:11,020
Ball is going to be true or false.

60
00:03:11,020 --> 00:03:14,740
So we're going to call this is running because is running is either true.

61
00:03:14,740 --> 00:03:15,970
That means you're running or it's false.

62
00:03:15,970 --> 00:03:16,810
That means you're not running.

63
00:03:16,810 --> 00:03:18,220
So it is running.

64
00:03:18,220 --> 00:03:23,170
And then over in the conditions we'll click plus by default is running as populated in there and is

65
00:03:23,170 --> 00:03:24,100
running is true.

66
00:03:24,100 --> 00:03:27,010
That means if we're running, go into the running state.

67
00:03:27,010 --> 00:03:32,530
Now I'm going to click on the running animation again, right click make transition back to Idle.

68
00:03:32,560 --> 00:03:34,450
Actually, while I'm here, I'm going to click on Idle.

69
00:03:34,460 --> 00:03:39,400
I'm going to change the name of this to idling because I'm idling, I'm running, I'm climbing.

70
00:03:39,400 --> 00:03:41,380
So we'll use that naming convention in here.

71
00:03:41,380 --> 00:03:43,900
It doesn't matter a great deal, but I like to have these things match up.

72
00:03:43,900 --> 00:03:48,790
I'm going to click on this transition line, set my duration down to zero once again, exit time to

73
00:03:48,790 --> 00:03:51,460
zero once again and turn off has exit time.

74
00:03:51,460 --> 00:03:53,800
Click on the criteria here.

75
00:03:53,800 --> 00:03:55,030
Just a little challenge for you.

76
00:03:55,030 --> 00:03:56,470
What do we need to set this to?

77
00:03:56,920 --> 00:03:58,870
Well, is running needs to be false.

78
00:03:58,870 --> 00:04:03,040
The other thing I'll do while I'm here, click on running animation and we need to make sure we have

79
00:04:03,060 --> 00:04:03,670
loop time.

80
00:04:03,670 --> 00:04:06,580
So it loops over and over and over and doesn't just play one time.

81
00:04:06,580 --> 00:04:09,970
Now if we click on play, that will take us to the game window.

82
00:04:09,970 --> 00:04:13,180
I'm just going to click back on the scene window because I can zoom in a little bit closer.

83
00:04:13,180 --> 00:04:15,070
It makes it easier to see what's going on.

84
00:04:15,070 --> 00:04:20,350
And in our parameters, if I click this checkbox, we should go into our running animation and this

85
00:04:20,350 --> 00:04:21,850
is what we'll be doing in code.

86
00:04:21,850 --> 00:04:26,380
Now we can just click it manually, click it on and click it off, and that will change from one state

87
00:04:26,380 --> 00:04:26,740
to another.

88
00:04:26,740 --> 00:04:28,840
So it should change from running to idling.

89
00:04:28,840 --> 00:04:32,980
When we're clicking on that, this is what we'll be doing in our code in upcoming lectures, which is

90
00:04:32,980 --> 00:04:33,730
going to be really cool.

91
00:04:33,730 --> 00:04:34,960
We can visualize it here.

92
00:04:34,960 --> 00:04:38,350
Now if you find your running's a little bit slow, which I kind of am finding in here, then we can

93
00:04:38,350 --> 00:04:44,470
hop out of play mode, we can go over to running animation, we can go to the running state and we can

94
00:04:44,470 --> 00:04:48,040
change the speed to say, oh, 1.5, click on play.

95
00:04:48,040 --> 00:04:50,800
I might be able to do that in play mode actually, and keep the changes.

96
00:04:50,800 --> 00:04:53,170
Then click on just back to see it again.

97
00:04:53,170 --> 00:04:55,300
Click on Running, Run, Run, Run, Run.

98
00:04:55,300 --> 00:04:57,880
That seems like a little bit more of a brisk run, doesn't it?

99
00:04:57,880 --> 00:04:58,510
That's pretty good.

100
00:04:58,510 --> 00:04:59,320
If we change this.

101
00:04:59,320 --> 00:05:01,600
Let me just do a little experiment while I'm in play mode.

102
00:05:01,600 --> 00:05:02,620
Hop out of play mode.

103
00:05:02,700 --> 00:05:05,720
It does retain that that change that we make, which is cool.

104
00:05:05,730 --> 00:05:09,990
1.5 as you know, a lot of things don't retain, but this seems to be retained now.

105
00:05:10,020 --> 00:05:12,240
Next up, we're going to implement our ladder climb.

106
00:05:12,240 --> 00:05:17,190
So back over to our sprites will find our sprite sheet, click on Sprite editor, have a look at what's

107
00:05:17,190 --> 00:05:17,550
going on.

108
00:05:17,550 --> 00:05:23,790
It's going to be these two just here and they are 14 and 15 that will be implementing.

109
00:05:23,790 --> 00:05:26,220
So it's frame 14 and 15 will be setting up.

110
00:05:26,220 --> 00:05:31,590
And I want you to do this as a challenge to implement climbing animation state, create a transition

111
00:05:31,590 --> 00:05:36,510
from idling to climbing that's important and create a trigger for the climbing state that we can test

112
00:05:36,510 --> 00:05:38,820
it and go about do doing your testing.

113
00:05:38,820 --> 00:05:39,870
So pause the video.

114
00:05:39,870 --> 00:05:40,440
Take that on.

115
00:05:40,440 --> 00:05:41,820
I'll see you back here when you're done.

116
00:05:44,850 --> 00:05:45,270
Okay.

117
00:05:45,270 --> 00:05:47,370
First step we'll go into.

118
00:05:47,370 --> 00:05:49,440
I forgot the numbers I selected already on here.

119
00:05:49,440 --> 00:05:53,880
It was 14 and 15, so we'll find 14 and 15.

120
00:05:53,880 --> 00:05:54,750
I didn't do anything there.

121
00:05:54,750 --> 00:05:55,860
14 and 15.

122
00:05:55,860 --> 00:05:56,940
Sounded like I was in trouble.

123
00:05:56,940 --> 00:05:58,080
Didn't I didn't do anything.

124
00:05:58,110 --> 00:05:59,010
Don't make the change.

125
00:05:59,010 --> 00:05:59,910
I like both of those.

126
00:05:59,910 --> 00:06:02,520
Right click create animation.

127
00:06:02,520 --> 00:06:09,030
We'll call this animation climbing or drag climbing over into animations from animation folder will

128
00:06:09,030 --> 00:06:13,650
drag climbing into our animated controller.

129
00:06:13,650 --> 00:06:17,010
Pop it over to the right here because I want this coming off idling as well.

130
00:06:17,010 --> 00:06:22,200
We're going to go if we stop running then and we start climbing, we'll transition through idling.

131
00:06:22,230 --> 00:06:25,380
To do that, we don't need to go directly from running to climbing.

132
00:06:25,380 --> 00:06:26,970
It'll just be not running.

133
00:06:26,970 --> 00:06:27,360
Okay.

134
00:06:27,360 --> 00:06:28,110
AM climbing.

135
00:06:28,110 --> 00:06:29,400
That's the logic I'm going to use here.

136
00:06:29,400 --> 00:06:32,520
So right click make transition over to climbing while I'm here.

137
00:06:32,520 --> 00:06:35,310
Right click may transition back to idling.

138
00:06:35,310 --> 00:06:40,210
I'm going to create my parameter while I'm here, which will be a ball we'll call this is climbing now

139
00:06:40,210 --> 00:06:42,750
we'll click on the from idle to climbing.

140
00:06:42,750 --> 00:06:45,900
Change our settings in here down to zero down to zero.

141
00:06:45,900 --> 00:06:47,640
Turn this guy down to zero.

142
00:06:47,640 --> 00:06:48,690
Turn that guy off.

143
00:06:48,690 --> 00:06:52,620
We'll add our condition which will be is climbing is true.

144
00:06:52,620 --> 00:06:53,040
Yes.

145
00:06:53,040 --> 00:07:00,210
Now on the way back again we will drop the transition doesn't have an exit time and we will click plus

146
00:07:00,210 --> 00:07:02,700
and is climbing is false.

147
00:07:02,700 --> 00:07:03,300
Okay.

148
00:07:03,300 --> 00:07:08,160
Now I'm just going to click my running checkbox here, click on play to test out to see if climbing

149
00:07:08,160 --> 00:07:08,760
works.

150
00:07:08,760 --> 00:07:12,570
Not doing anything at the moment, just idling, hanging out chilling click on is climbing.

151
00:07:13,290 --> 00:07:16,380
Okay, I forgot to do looping.

152
00:07:16,380 --> 00:07:18,420
So click on our climbing animation.

153
00:07:18,420 --> 00:07:19,110
Click on looping.

154
00:07:19,110 --> 00:07:24,000
I think I've forgotten to do looping for every single animation I've done so far in this section of

155
00:07:24,000 --> 00:07:24,690
the course.

156
00:07:24,690 --> 00:07:26,520
Click on scene climbing.

157
00:07:27,000 --> 00:07:27,960
Oh, that's really fast.

158
00:07:27,960 --> 00:07:29,190
Maybe a little bit too fast.

159
00:07:29,190 --> 00:07:34,140
So I'm just going to quickly turn the climbing down to say .8.75.

160
00:07:34,140 --> 00:07:39,690
Maybe it's too fast because we've only got the two frames, so it's just flicking between those two.

161
00:07:39,690 --> 00:07:40,260
That's fine.

162
00:07:40,260 --> 00:07:45,420
And we need to have a way of saying, when you're stopped, stay in this state, but don't actually

163
00:07:45,420 --> 00:07:46,140
play the animation.

164
00:07:46,140 --> 00:07:50,020
We'll play around with that later on because we don't want a player stopped on the ladder and be like.

165
00:07:50,040 --> 00:07:51,240
Da da da da da da like that.

166
00:07:51,240 --> 00:07:52,200
We'll figure that out later on.

167
00:07:52,200 --> 00:07:55,680
So now we've got our running state and our climbing state misbehaves a little bit if you click them

168
00:07:55,680 --> 00:07:56,550
both at the same time.

169
00:07:56,550 --> 00:07:59,220
But in our code logic, we won't let the player do that.

170
00:07:59,220 --> 00:08:00,510
You'll be doing one or the other.

171
00:08:00,510 --> 00:08:01,050
So there we go.

172
00:08:01,080 --> 00:08:06,030
We've got some cool animation states that will allow us to have our character come to life when we actually

173
00:08:06,030 --> 00:08:07,860
start moving it around on the screen.

174
00:08:07,860 --> 00:08:09,210
So great work in this lecture.

175
00:08:09,210 --> 00:08:10,410
I will see you in the next one.

