﻿1
00:00:04,440 --> 00:00:04,830
‫Hello.

2
00:00:04,830 --> 00:00:05,340
‫Welcome.

3
00:00:05,340 --> 00:00:09,330
‫In this lecture, we are going to get our foot sliding in order.

4
00:00:09,330 --> 00:00:09,900
‫As you can see.

5
00:00:09,900 --> 00:00:12,900
‫Now, if I'm walking, my feet are no longer sliding.

6
00:00:12,900 --> 00:00:15,630
‫And if I'm running the same, I'm also not sliding.

7
00:00:15,630 --> 00:00:20,820
‫So let's dive in and see how we can do this by calculating the speed of our animations.

8
00:00:21,620 --> 00:00:24,890
‫So let's try and fix this foot sliding issue.

9
00:00:24,890 --> 00:00:31,430
‫If I'm moving especially visible at a slow walking speed, you can see he's basically running across

10
00:00:31,430 --> 00:00:32,100
‫the ground.

11
00:00:32,120 --> 00:00:33,890
‫Now, why is this happening?

12
00:00:33,980 --> 00:00:41,780
‫The reason this is happening is that in our blend space, locomotion, we have got some speeds set up

13
00:00:41,780 --> 00:00:42,230
‫here.

14
00:00:42,230 --> 00:00:45,710
‫And these don't actually correspond to the speeds of our animation.

15
00:00:45,710 --> 00:00:52,490
‫So what we're saying is that in gameplay, we're moving at 100 centimeters a second, is going to be

16
00:00:52,490 --> 00:00:53,750
‫playing this running animation.

17
00:00:53,750 --> 00:00:58,850
‫And if this running animation is faster than 100 centimeters per second, you're going to get foot sliding.

18
00:00:58,850 --> 00:01:00,860
‫Also, if it's slower, you're going to get foot sliding.

19
00:01:00,860 --> 00:01:02,810
‫In both cases, you'll get foot sliding.

20
00:01:02,810 --> 00:01:09,590
‫So what we want to do is match up these axes to actually play the correct animation at the correct speed

21
00:01:09,590 --> 00:01:12,680
‫and then interpolate when we're at a different speed.

22
00:01:12,830 --> 00:01:16,640
‫Obviously, this is going to mean that there is a limitation on our gameplay.

23
00:01:16,640 --> 00:01:25,370
‫We can't go faster than our maximum animation will allow because we are unable to display that.

24
00:01:25,370 --> 00:01:31,130
‫But if you did want to do that and you did want to go faster, then you would have to get more animations

25
00:01:31,130 --> 00:01:31,550
‫and so on.

26
00:01:31,550 --> 00:01:37,790
‫But as I said, that allows our designer to change up the gameplay first and then we can go and hunt

27
00:01:37,790 --> 00:01:39,410
‫for animations if it works.

28
00:01:39,740 --> 00:01:43,220
‫So let's have a look at this run animation.

29
00:01:43,220 --> 00:01:45,740
‫How can we calculate the speed of this run animation?

30
00:01:45,740 --> 00:01:52,160
‫It's not automatically told to us by Unreal, so there's a little bit of maths involved to get there.

31
00:01:52,160 --> 00:02:00,530
‫Let's go and find the jog forward animation and we want the jog forward combat in particular.

32
00:02:01,010 --> 00:02:01,820
‫Here it is.

33
00:02:02,000 --> 00:02:03,830
‫And how do we go ahead and get this?

34
00:02:03,830 --> 00:02:06,470
‫Let's just pause the playing of the animation.

35
00:02:07,040 --> 00:02:13,160
‫What we want to see essentially is how fast one of these feet moves across the floor.

36
00:02:13,160 --> 00:02:20,960
‫So from the point it touches down to the point that it is starting to leave the floor, we want to know

37
00:02:20,960 --> 00:02:23,450
‫how fast it moved across the ground.

38
00:02:23,450 --> 00:02:25,940
‫And that is the speed of animation.

39
00:02:26,300 --> 00:02:31,100
‫To do that, we are going to track the speed of the ankle bone.

40
00:02:31,100 --> 00:02:38,660
‫So if I click into the world, you can see I should be able to select the foot, underscore R As of

41
00:02:38,660 --> 00:02:43,370
‫Unreal five, you're no longer able to actually click into the viewport to select the bone.

42
00:02:43,370 --> 00:02:48,350
‫So what you'll have to do is go over into the skeleton tab over in the left and use the search bar to

43
00:02:48,350 --> 00:02:49,490
‫search for this bone.

44
00:02:49,820 --> 00:02:51,260
‫And that is our ankle bone.

45
00:02:51,260 --> 00:02:56,780
‫And as we move across, you can see that it is moving the rotation, but notice it's not changing the

46
00:02:56,780 --> 00:02:57,320
‫location.

47
00:02:57,320 --> 00:02:58,070
‫Why is that?

48
00:02:58,280 --> 00:03:02,840
‫Because the location shown here is a local rotation, local location, rather.

49
00:03:02,840 --> 00:03:08,360
‫And that location is relative to the knee and it's not actually moving relative to the knee.

50
00:03:08,360 --> 00:03:10,610
‫It's only rotating relative to the knee.

51
00:03:10,610 --> 00:03:12,620
‫So that's why we are getting that.

52
00:03:12,620 --> 00:03:20,420
‫If we switch over to the world location and go ahead and move now, you can definitely see that we're

53
00:03:20,420 --> 00:03:23,180
‫getting movements in our location.

54
00:03:23,180 --> 00:03:30,020
‫So we need to switch over to world for this calculation to work and then we want to find two points.

55
00:03:30,020 --> 00:03:36,200
‫The point at which we land, we are going to want to find out the y value, y the y value, because

56
00:03:36,200 --> 00:03:39,710
‫that is this axis here that we're looking at from left to right.

57
00:03:39,710 --> 00:03:40,580
‫It's the y axis.

58
00:03:40,580 --> 00:03:44,330
‫You can see it in the widget at the bottom left of your viewport.

59
00:03:44,330 --> 00:03:48,230
‫So we're going to want to find the Y value when we hit the floor.

60
00:03:48,230 --> 00:03:53,000
‫We're also going to want to find the time at which we hit the floor, which is this second number in

61
00:03:53,000 --> 00:03:56,990
‫brackets on our timeline, the 0.19.

62
00:03:57,620 --> 00:04:02,720
‫And we're going to then go and look and find the second time, which is where we're going to leave the

63
00:04:02,720 --> 00:04:05,540
‫floor, find that time, find the Y value.

64
00:04:05,540 --> 00:04:08,300
‫And then we're going to apply this formula here.

65
00:04:08,300 --> 00:04:09,410
‫Let me break it down.

66
00:04:09,440 --> 00:04:11,750
‫The first thing is to calculate the foot speed.

67
00:04:11,750 --> 00:04:16,490
‫We need to calculate the Y at the finish minus the Y at the start.

68
00:04:16,600 --> 00:04:22,160
‫We want to divide that by the time at the finish divided by the time at the start.

69
00:04:22,160 --> 00:04:24,170
‫So I'm going to work through this calculation with you.

70
00:04:24,200 --> 00:04:29,360
‫All you're going to need is somewhere to capture the numbers, such as a new notepad, or I'm going

71
00:04:29,360 --> 00:04:33,800
‫to use a new text document in a Visual Studio code, just an untitled one.

72
00:04:33,800 --> 00:04:38,860
‫I don't need to save it or anything, and I'm going to open up a calculator on Windows.

73
00:04:38,870 --> 00:04:43,910
‫It's just easier to do it on your computer because you can copy and paste into it.

74
00:04:44,720 --> 00:04:47,240
‫And we're going to start finding some values.

75
00:04:47,240 --> 00:04:52,880
‫First of all, we want to find where do we hit the floor about here, which is going to be a time,

76
00:04:52,880 --> 00:04:55,790
‫0.16.

77
00:04:55,790 --> 00:04:58,310
‫Let's type that in to our text document.

78
00:04:58,310 --> 00:05:01,400
‫1.16.

79
00:05:02,250 --> 00:05:04,170
‫I go one six like that.

80
00:05:04,260 --> 00:05:06,300
‫And what's the Y value?

81
00:05:06,330 --> 00:05:09,270
‫Best to capture it now because it's going to be hard to find later.

82
00:05:09,360 --> 00:05:10,310
‫It is.

83
00:05:10,320 --> 00:05:15,420
‫Let's just go ahead and copy it because it's hard to see at my screen, resolution 17 point something

84
00:05:15,420 --> 00:05:15,960
‫cool.

85
00:05:16,200 --> 00:05:17,660
‫Now that's the start.

86
00:05:17,670 --> 00:05:19,410
‫Where is the finish?

87
00:05:19,440 --> 00:05:21,680
‫Let's go and drag the foot across.

88
00:05:21,690 --> 00:05:32,280
‫Around here is probably where we're leaving the ground and it is conveniently 0.30 and the Y is going

89
00:05:32,280 --> 00:05:36,930
‫to be a negative number now minus to eight point vega.

90
00:05:37,740 --> 00:05:39,830
‫So let's apply our formula.

91
00:05:39,840 --> 00:05:42,000
‫First of all, it's the finish that we want in there.

92
00:05:42,000 --> 00:05:43,040
‫First, not the start.

93
00:05:43,050 --> 00:05:46,590
‫Counterintuitively, we're going to subtract the start.

94
00:05:47,700 --> 00:05:48,360
‫Like that.

95
00:05:48,390 --> 00:05:51,210
‫It's going to give us a negative number of that's how far we moved.

96
00:05:51,210 --> 00:05:54,870
‫45 centimeters is how far that foot moved in one stride.

97
00:05:55,050 --> 00:05:57,590
‫Now, how long did it take for that to happen?

98
00:05:57,600 --> 00:06:03,570
‫First of all, let's let's get that number down in our file, in our text file and see how long it took.

99
00:06:03,570 --> 00:06:06,600
‫Let's clear and start with the finish.

100
00:06:07,450 --> 00:06:09,460
‫And then subtract.

101
00:06:10,240 --> 00:06:13,450
‫The start gives us this number.

102
00:06:13,570 --> 00:06:18,670
‫So I'm going to copy which is control C on Windows without selecting anything, it just automatically

103
00:06:18,670 --> 00:06:19,930
‫copies the number that's there.

104
00:06:20,530 --> 00:06:22,930
‫And then we're going to want to work out what this is equal to.

105
00:06:22,960 --> 00:06:29,140
‫So let's clear and start with the -45 and divide.

106
00:06:29,960 --> 00:06:31,970
‫By the 0.14.

107
00:06:32,600 --> 00:06:35,360
‫And to gives us this number right here.

108
00:06:36,140 --> 00:06:36,980
‫Like that.

109
00:06:38,420 --> 00:06:43,550
‫So this is telling us that our jog speed is giving us a negative number because that's kind of going

110
00:06:43,550 --> 00:06:44,450
‫backwards.

111
00:06:44,450 --> 00:06:52,940
‫But the jog speed forwards essentially is going to be 325, approximately centimeters per second.

112
00:06:52,940 --> 00:06:56,900
‫So that's what we're going to want to have in our blend space.

113
00:06:58,350 --> 00:07:02,190
‫So we now need to do the same thing for our walking animation.

114
00:07:02,190 --> 00:07:07,080
‫So that's going to be a challenge for you to calculate the walk speed as well as the run speed find

115
00:07:07,080 --> 00:07:11,940
‫the walking animation that's relevant, probably the forward one, and apply the formula and do it the

116
00:07:11,940 --> 00:07:13,260
‫same as we just did.

117
00:07:13,260 --> 00:07:19,290
‫Finding the foot speed is why finish minus y start divided by t finish minus t start.

118
00:07:19,290 --> 00:07:23,610
‫So pause the video and have a go and see what speed you come up with.

119
00:07:24,400 --> 00:07:24,640
‫Okay.

120
00:07:24,640 --> 00:07:25,120
‫Welcome back.

121
00:07:25,120 --> 00:07:29,800
‫So let's go and find what is the correct thing here.

122
00:07:29,800 --> 00:07:36,280
‫We're going to want to find, first of all, our blend space and see what animation we were using just

123
00:07:36,280 --> 00:07:37,780
‫to jog our memories.

124
00:07:38,080 --> 00:07:47,350
‫The value here is the MP walk forward, so let's find that out and B walk forward.

125
00:07:47,350 --> 00:07:52,540
‫Let's open that animation up and we should see that it's going to be a much slower animation than the

126
00:07:52,540 --> 00:07:56,380
‫other one and we're going to find our values.

127
00:07:56,380 --> 00:08:01,780
‫So first of all, let's find the plant that's about here after the foot started moving is probably the

128
00:08:01,780 --> 00:08:03,760
‫best place like that.

129
00:08:04,180 --> 00:08:07,150
‫So that is let's go and add some new lines in here.

130
00:08:07,150 --> 00:08:15,970
‫It's going to be 0.34 like so and go and find the details of this foot bone.

131
00:08:15,970 --> 00:08:21,520
‫So like the foot bone world, we've already got selected and we're going to find its location.

132
00:08:21,520 --> 00:08:27,340
‫That's why then we go and move the foot back until we're almost leaving the ground, which is going

133
00:08:27,340 --> 00:08:28,630
‫to be at zero point.

134
00:08:29,440 --> 00:08:30,700
‫Six seven.

135
00:08:31,400 --> 00:08:35,240
‫And the why is going to be a -22 thing.

136
00:08:35,540 --> 00:08:36,020
‫There you go.

137
00:08:36,290 --> 00:08:38,450
‫Moving the same distance, sort of.

138
00:08:38,450 --> 00:08:42,080
‫But you can see that the time taken is much longer.

139
00:08:42,080 --> 00:08:43,770
‫So it's going to be much slower.

140
00:08:43,790 --> 00:08:45,860
‫So let's open up our calculator again.

141
00:08:46,990 --> 00:08:50,620
‫And first of all, calculate the finish minus the start.

142
00:08:50,620 --> 00:08:54,610
‫So finish minus the start.

143
00:08:55,360 --> 00:08:56,740
‫Gives us this.

144
00:08:58,500 --> 00:09:00,390
‫Say, as you see very similar distance.

145
00:09:00,630 --> 00:09:04,290
‫And probably if I'd select a different timestamps, it would have been the same distance.

146
00:09:04,560 --> 00:09:06,420
‫Then we're going to get the finish time.

147
00:09:06,420 --> 00:09:12,060
‫So clear this finish time minus the start time.

148
00:09:13,030 --> 00:09:16,310
‫It gives us a much longer time, almost twice as long.

149
00:09:16,310 --> 00:09:19,760
‫So I'm assuming it's going to be almost twice as slow.

150
00:09:19,880 --> 00:09:24,200
‫So let's clear and get our 42.

151
00:09:25,260 --> 00:09:28,380
‫Divided by 0.33.

152
00:09:30,120 --> 00:09:37,110
‫Gives us indeed something that's more like minus or basically 130.

153
00:09:38,010 --> 00:09:39,390
‫So I copy that.

154
00:09:39,930 --> 00:09:43,530
‫Interestingly, when it's the bigger form, it doesn't copy as easily.

155
00:09:43,680 --> 00:09:44,490
‫There you go.

156
00:09:44,520 --> 00:09:50,910
‫So this is basically our speed, 130 and 3 to 5.

157
00:09:51,180 --> 00:09:53,730
‫Now, how do we get this in to our blend space?

158
00:09:53,730 --> 00:09:54,870
‫That wasn't part of your challenge.

159
00:09:54,870 --> 00:09:56,460
‫But we're going to do this now.

160
00:09:56,490 --> 00:10:02,820
‫Let's open up our blend space location, because these divisions aren't so easy for us to do that.

161
00:10:04,410 --> 00:10:08,270
‫Well, the first thing is that we don't need to get things exactly 100% right.

162
00:10:08,280 --> 00:10:16,620
‫But the second thing is that we can change the divisions or the number of divisions on our speed axis.

163
00:10:17,490 --> 00:10:23,340
‫So the way I'm going to do this is I'm going to round these two values to approximately the nearest

164
00:10:23,340 --> 00:10:26,550
‫50 and use 50 divisions.

165
00:10:26,550 --> 00:10:31,770
‫So what we'd have here is this one's going to round up to 350.

166
00:10:31,800 --> 00:10:34,290
‫This one's going to round up to 150.

167
00:10:34,650 --> 00:10:38,010
‫And then what we can do is figure out how many divisions we need.

168
00:10:38,310 --> 00:10:42,720
‫So 350 divided by 50 is going to give us seven.

169
00:10:42,960 --> 00:10:45,150
‫So let's go to our speed.

170
00:10:45,150 --> 00:10:52,590
‫And in seven divisions, add the maximum axis value to be 350 like so.

171
00:10:52,590 --> 00:11:01,080
‫And now what we should get is at the 350 mark, we are going to be running when we're down at 150,

172
00:11:01,080 --> 00:11:03,090
‫we are going to be walking.

173
00:11:03,090 --> 00:11:07,500
‫So if we save and then anywhere in between, obviously it's going to interpolate as best it can.

174
00:11:07,980 --> 00:11:13,210
‫Now let's go ahead and play and see if that's helped fix our foot sliding issue.

175
00:11:13,230 --> 00:11:15,560
‫Let's look down at the ground so we can see our feet.

176
00:11:15,570 --> 00:11:22,050
‫As I am walking, you can see we've got far less if no foot sliding whatsoever as we run.

177
00:11:22,050 --> 00:11:24,870
‫It's certainly no noticeable foot sliding now.

178
00:11:24,870 --> 00:11:32,970
‫So I'm quite happy that we've successfully calculated a decent approximation for the speed of our animations

179
00:11:33,420 --> 00:11:37,740
‫and hopefully you can apply this to any animations that you use in the future if you're trying to put

180
00:11:37,740 --> 00:11:41,850
‫them in a blend space or match them up to our foot movement.

181
00:11:43,270 --> 00:11:46,300
‫So that concludes our little foray into animation.

182
00:11:46,300 --> 00:11:52,120
‫For now, I think we've got a good starting point for our animation with a third person character.

183
00:11:52,150 --> 00:11:56,710
‫The next thing that's really missing here is some gun architecture.

184
00:11:56,710 --> 00:12:03,130
‫So we're going to look at how you architect guns for third person and first person shooters in the next

185
00:12:03,130 --> 00:12:03,630
‫lecture.

186
00:12:03,640 --> 00:12:04,420
‫See you there.

