‫Hello.
‫Welcome.
‫In this lecture, we are going to get our foot sliding in order.
‫As you can see.
‫Now, if I'm walking, my feet are no longer sliding.
‫And if I'm running the same, I'm also not sliding.
‫So let's dive in and see how we can do this by calculating the speed of our animations.
‫So let's try and fix this foot sliding issue.
‫If I'm moving especially visible at a slow walking speed, you can see he's basically running across
‫the ground.
‫Now, why is this happening?
‫The reason this is happening is that in our blend space, locomotion, we have got some speeds set up
‫here.
‫And these don't actually correspond to the speeds of our animation.
‫So what we're saying is that in gameplay, we're moving at 100 centimeters a second, is going to be
‫playing this running animation.
‫And if this running animation is faster than 100 centimeters per second, you're going to get foot sliding.
‫Also, if it's slower, you're going to get foot sliding.
‫In both cases, you'll get foot sliding.
‫So what we want to do is match up these axes to actually play the correct animation at the correct speed
‫and then interpolate when we're at a different speed.
‫Obviously, this is going to mean that there is a limitation on our gameplay.
‫We can't go faster than our maximum animation will allow because we are unable to display that.
‫But if you did want to do that and you did want to go faster, then you would have to get more animations
‫and so on.
‫But as I said, that allows our designer to change up the gameplay first and then we can go and hunt
‫for animations if it works.
‫So let's have a look at this run animation.
‫How can we calculate the speed of this run animation?
‫It's not automatically told to us by Unreal, so there's a little bit of maths involved to get there.
‫Let's go and find the jog forward animation and we want the jog forward combat in particular.
‫Here it is.
‫And how do we go ahead and get this?
‫Let's just pause the playing of the animation.
‫What we want to see essentially is how fast one of these feet moves across the floor.
‫So from the point it touches down to the point that it is starting to leave the floor, we want to know
‫how fast it moved across the ground.
‫And that is the speed of animation.
‫To do that, we are going to track the speed of the ankle bone.
‫So if I click into the world, you can see I should be able to select the foot, underscore R As of
‫Unreal five, you're no longer able to actually click into the viewport to select the bone.
‫So what you'll have to do is go over into the skeleton tab over in the left and use the search bar to
‫search for this bone.
‫And that is our ankle bone.
‫And as we move across, you can see that it is moving the rotation, but notice it's not changing the
‫location.
‫Why is that?
‫Because the location shown here is a local rotation, local location, rather.
‫And that location is relative to the knee and it's not actually moving relative to the knee.
‫It's only rotating relative to the knee.
‫So that's why we are getting that.
‫If we switch over to the world location and go ahead and move now, you can definitely see that we're
‫getting movements in our location.
‫So we need to switch over to world for this calculation to work and then we want to find two points.
‫The point at which we land, we are going to want to find out the y value, y the y value, because
‫that is this axis here that we're looking at from left to right.
‫It's the y axis.
‫You can see it in the widget at the bottom left of your viewport.
‫So we're going to want to find the Y value when we hit the floor.
‫We're also going to want to find the time at which we hit the floor, which is this second number in
‫brackets on our timeline, the 0.19.
‫And we're going to then go and look and find the second time, which is where we're going to leave the
‫floor, find that time, find the Y value.
‫And then we're going to apply this formula here.
‫Let me break it down.
‫The first thing is to calculate the foot speed.
‫We need to calculate the Y at the finish minus the Y at the start.
‫We want to divide that by the time at the finish divided by the time at the start.
‫So I'm going to work through this calculation with you.
‫All you're going to need is somewhere to capture the numbers, such as a new notepad, or I'm going
‫to use a new text document in a Visual Studio code, just an untitled one.
‫I don't need to save it or anything, and I'm going to open up a calculator on Windows.
‫It's just easier to do it on your computer because you can copy and paste into it.
‫And we're going to start finding some values.
‫First of all, we want to find where do we hit the floor about here, which is going to be a time,
‫0.16.
‫Let's type that in to our text document.
‫1.16.
‫I go one six like that.
‫And what's the Y value?
‫Best to capture it now because it's going to be hard to find later.
‫It is.
‫Let's just go ahead and copy it because it's hard to see at my screen, resolution 17 point something
‫cool.
‫Now that's the start.
‫Where is the finish?
‫Let's go and drag the foot across.
‫Around here is probably where we're leaving the ground and it is conveniently 0.30 and the Y is going
‫to be a negative number now minus to eight point vega.
‫So let's apply our formula.
‫First of all, it's the finish that we want in there.
‫First, not the start.
‫Counterintuitively, we're going to subtract the start.
‫Like that.
‫It's going to give us a negative number of that's how far we moved.
‫45 centimeters is how far that foot moved in one stride.
‫Now, how long did it take for that to happen?
‫First of all, let's let's get that number down in our file, in our text file and see how long it took.
‫Let's clear and start with the finish.
‫And then subtract.
‫The start gives us this number.
‫So I'm going to copy which is control C on Windows without selecting anything, it just automatically
‫copies the number that's there.
‫And then we're going to want to work out what this is equal to.
‫So let's clear and start with the -45 and divide.
‫By the 0.14.
‫And to gives us this number right here.
‫Like that.
‫So this is telling us that our jog speed is giving us a negative number because that's kind of going
‫backwards.
‫But the jog speed forwards essentially is going to be 325, approximately centimeters per second.
‫So that's what we're going to want to have in our blend space.
‫So we now need to do the same thing for our walking animation.
‫So that's going to be a challenge for you to calculate the walk speed as well as the run speed find
‫the walking animation that's relevant, probably the forward one, and apply the formula and do it the
‫same as we just did.
‫Finding the foot speed is why finish minus y start divided by t finish minus t start.
‫So pause the video and have a go and see what speed you come up with.
‫Okay.
‫Welcome back.
‫So let's go and find what is the correct thing here.
‫We're going to want to find, first of all, our blend space and see what animation we were using just
‫to jog our memories.
‫The value here is the MP walk forward, so let's find that out and B walk forward.
‫Let's open that animation up and we should see that it's going to be a much slower animation than the
‫other one and we're going to find our values.
‫So first of all, let's find the plant that's about here after the foot started moving is probably the
‫best place like that.
‫So that is let's go and add some new lines in here.
‫It's going to be 0.34 like so and go and find the details of this foot bone.
‫So like the foot bone world, we've already got selected and we're going to find its location.
‫That's why then we go and move the foot back until we're almost leaving the ground, which is going
‫to be at zero point.
‫Six seven.
‫And the why is going to be a -22 thing.
‫There you go.
‫Moving the same distance, sort of.
‫But you can see that the time taken is much longer.
‫So it's going to be much slower.
‫So let's open up our calculator again.
‫And first of all, calculate the finish minus the start.
‫So finish minus the start.
‫Gives us this.
‫Say, as you see very similar distance.
‫And probably if I'd select a different timestamps, it would have been the same distance.
‫Then we're going to get the finish time.
‫So clear this finish time minus the start time.
‫It gives us a much longer time, almost twice as long.
‫So I'm assuming it's going to be almost twice as slow.
‫So let's clear and get our 42.
‫Divided by 0.33.
‫Gives us indeed something that's more like minus or basically 130.
‫So I copy that.
‫Interestingly, when it's the bigger form, it doesn't copy as easily.
‫There you go.
‫So this is basically our speed, 130 and 3 to 5.
‫Now, how do we get this in to our blend space?
‫That wasn't part of your challenge.
‫But we're going to do this now.
‫Let's open up our blend space location, because these divisions aren't so easy for us to do that.
‫Well, the first thing is that we don't need to get things exactly 100% right.
‫But the second thing is that we can change the divisions or the number of divisions on our speed axis.
‫So the way I'm going to do this is I'm going to round these two values to approximately the nearest
‫50 and use 50 divisions.
‫So what we'd have here is this one's going to round up to 350.
‫This one's going to round up to 150.
‫And then what we can do is figure out how many divisions we need.
‫So 350 divided by 50 is going to give us seven.
‫So let's go to our speed.
‫And in seven divisions, add the maximum axis value to be 350 like so.
‫And now what we should get is at the 350 mark, we are going to be running when we're down at 150,
‫we are going to be walking.
‫So if we save and then anywhere in between, obviously it's going to interpolate as best it can.
‫Now let's go ahead and play and see if that's helped fix our foot sliding issue.
‫Let's look down at the ground so we can see our feet.
‫As I am walking, you can see we've got far less if no foot sliding whatsoever as we run.
‫It's certainly no noticeable foot sliding now.
‫So I'm quite happy that we've successfully calculated a decent approximation for the speed of our animations
‫and hopefully you can apply this to any animations that you use in the future if you're trying to put
‫them in a blend space or match them up to our foot movement.
‫So that concludes our little foray into animation.
‫For now, I think we've got a good starting point for our animation with a third person character.
‫The next thing that's really missing here is some gun architecture.
‫So we're going to look at how you architect guns for third person and first person shooters in the next
‫lecture.
‫See you there.