Download

How to Slow down root motion velocity procedurally?

Hi,

I’m trying to figure out how to modify root motion velocity procedurally, with a node in the anim graph or some other way.

For example: I have a root motion animation of the character walking at 100cm/s. What I want to do is to slow down the character speed by some ratio given as parameter (like alpha=0.5 the character should walk at 50cm/s) But I don’t wan’t to slow down the animation, so the rest of the character skeleton should animate normally, only the root bone should slow down. (There will be foot slip of course, but for what I need to do it’s not a problem)

Also, I need to pass this ratio as a dynamic parameter, so it will multiply the root bone velocity or increment. So if the root bone is not moving the speed will stay 0 and if it’s moving the speed should be multiplied by the alpha.

I cannot find anything to make it happen.

Okay, I found something. There is a SetAnimRootMotionTranslationScale method in Character class, but it’s not BP exposed, so I did this:



void UMyBlueprintFunctionLibrary::SetAnimRootMotionTranslationScale(ACharacter* Character, float InAnimRootMotionTranslationScale)
{
    if (Character)
    {
        Character->SetAnimRootMotionTranslationScale(InAnimRootMotionTranslationScale);
    }
}


But I’m still looking for purely AnimBP based solution.

The only thing that comes to mind as described is Speed Warping.

https://www.youtube.com/watch?v=IKL-aNbwq7w

You could scale the animation but that would scale both the velocity and animations.

The tricky part though is mixing in the use of root motion if the need is to slow down the character but not the animation.

If your animation is set to work for a step distance of 100cm/s changing it to 50cm/s will only get you a bad animation where the feet slide around.

Which is exactly why the speed warp node was made (btw does it work with the current engine or is it still crashing projects after it runs a while?)

If you want to alter the speed of the animation’s root bone you can always use a transform command on the bone.
what I would do is create custom curve values that match the root bone x direction speed.
then use that curve to drive the custom root bone speed.

that way you can multiply the curve by 1 or .5 and it’s exactly the ratio you expect.

The downside is that every animation that moves needs the speed curve.

The upside is that you could technically also control starting and ending speeds…

@FrankieV
I use SpeedWarp node, but it only changes the position of feet, not the overall speed. It’s supposed to be used with in-place motion I suppose. But the method I mentioned above works very well, so I use both and this way I have speed warping for root motion You can see the result and the setup in this tweet: https://twitter.com/games_inu/status…44674122190853

[USER=“3140864”]MostHost LA[/USER]
Warp node still crahes, and I found exactly where, there is a checkf which will misfire sometimes. I think this can be fixed.

Yep, replaced 2 checks in AnimNode_SpeedWarping.cpp at about line 214, and it works:


if (BoneLocation.ContainsNaN() || BoneVelocity.ContainsNaN()) return;

Giving that a try, just 'coz.