# Question How velocity is calculated in humanoid animations with root motion?

Discussion in 'Animation' started by MPaluszek, Jul 22, 2022.

1. ### MPaluszek

Joined:
Jan 17, 2019
Posts:
20
Hi,

Right now I'm trying to make tool that sets speed of animation to match velocity designer wants it to be, for example if run velocity is 2 and designer wants run to be 3, so speed parameter on animator state will be set to 1,5.

As it turns out apparentSpeed value in AnimationClip is not "real" velocity. After some digging I found that Animator has humanScale property (in my case it is 1.167) and it is applied to position delta in root motion. But still velocities don't match.

Even weirder thing is that multiplier needed desired velocity (with humanScale taken into account) to match real velocity is not constant. For running and walking animations it is around 1.2, but for walking while crouching it is around 1.8. Which looks like it is taking apparent "height" of character into account, even if they all use the same avatar from different file. And when you set avatar to "Craete From This Model" calculated velocity is different.
1. How velocity is calculated in humanoid animations with root motion?
2. How does apparent height of character in animation influences calculated average velocity?
3. Is there a way to get this height parameter from animation clip?

2. ### arfish

Joined:
Jan 28, 2017
Posts:
780
Hi,

Maybe you can measure how long steps the animated character takes.
For example, if a player with the height 1 walks 0.7 in each step. Then you know a player of height 2 will go 1.4 in each step.

The speed is the walked lenght divided by the clip time to complete a whole step, and the unit is m/s. And then you have a scale factor to translate from character speed to the animation speed.

3. ### MPaluszek

Joined:
Jan 17, 2019
Posts:
20
I've written not clearly enough, all those differences are within 1 character. The height I was talking about was apparent height (height of bounding box), so when crouching character is shorter than standing up and that is causing different multipliers (at least I think so).

But thanks for advice. I was hoping for something more easily calculateable, but as far as I researched it probably is the most accurate.

4. ### arfish

Joined:
Jan 28, 2017
Posts:
780
You should probably stop the player velocity while crouching, if its not a very slippery surface where the player should slide.

Last edited: Jul 25, 2022
5. ### sanchez_x

Joined:
Feb 9, 2019
Posts:
5
do you get any success with this? I'm also trying to calculate the velocity with no success. I'm so close to the real value, but something still influences the velocity and I can't figure out what.