Root motion doesn't move in the z-axis!

I created a simple jump animation for my character with one bone using Maya, two parameters are changing, the x parameter to move forward and Z parameter.

I put that animation inside an animation montage and enabled root motion options,the result isn’t as expected, what I get is a moving forward animation without any changing of Z values !

Is root motion locked into x-y axes ?or do I need manually to move up my character ?

1 Like

I got it !

thanks to this question Why is the root motion feature not allowing my character to climb? - Character & Animation - Unreal Engine Forums
It seems that root motion translation in UE4 ignores Z movement unless the player is in flying movement mode.
I should enable flying mode and returning it back to my default mode when my montage is done.

1 Like

This was really boggling me too! Thanks for the solution. I was even using a custom movement mode, but it does seem to have to be “flying”.

I would add to this slightly to say that, for me, UE4 seemed to ignore all translation when there was a Z component and movement mode was not flying. Rotation was applied though, regardless of movement mode.

1 Like

Hey I came up with another solution to the problem that doesn’t require changing the movement mode to flying. If you’re using C++ and a custom character movement component you can simply override the UCharacterMovementComponent::ConstrainAnimRootMotionVelocity
function. As you can see, in its implementation it is preventing the Z value from being overwritten:

FVector UCharacterMovementComponent::ConstrainAnimRootMotionVelocity(const FVector& RootMotionVelocity, const FVector& CurrentVelocity) const
{
	FVector Result = RootMotionVelocity;

	// Do not override Velocity.Z if in falling physics, we want to keep the effect of gravity.
	if (IsFalling())
	{
		Result.Z = CurrentVelocity.Z;
	}

	return Result;
}

I removed this in my override function like so and it worked great :slight_smile:

FVector UCustomCharacterMovementComponent::ConstrainAnimRootMotionVelocity(const FVector& RootMotionVelocity, const FVector& CurrentVelocity) const
{
	return RootMotionVelocity;
}
8 Likes