# Character Velocity change halved when falling

Hello!
I’ve found a very illogical code part in the character movement, I hope you could help me explain why is it good, and how to work around.
The problem is, I have a root motion with additive velocity, works great, except if the character is currently falling.

Found the problematic code:

``````void UCharacterMovementComponent::PhysFalling(float deltaTime, int32 Iterations)
{
....

FVector OldVelocity = Velocity;
FVector VelocityNoAirControl = Velocity;

// Apply input
.....

// Apply gravity
const FVector Gravity(0.f, 0.f, GetGravityZ());
Velocity = NewFallVelocity(Velocity, Gravity, timeTick);
VelocityNoAirControl = NewFallVelocity(VelocityNoAirControl, Gravity, timeTick);
const FVector AirControlAccel = (Velocity - VelocityNoAirControl) / timeTick;

ApplyRootMotionToVelocity(timeTick);

.....

// Move
FHitResult Hit(1.f);
FVector Adjusted = 0.5f*(OldVelocity + Velocity) * timeTick;
``````

If you look closely, it restores the additive root motion before setting “OldVelocity”. So when my character is controlled by root motion( I disable any other inputs, because I want the full control of the root motion + physics ), this will be FVector( 0, 0, Gravity + acceleration )

Then it applies the inputs which will be still 0.
Then applies the new Root motion velocity, which is great, in my test case the velocity here is: FVector( -500, -200, FallingSpeed ).

Then comes the funny part

``````FVector Adjusted = 0.5f*(OldVelocity + Velocity) * timeTick;
``````

So the final velocity will be at halfway between 0 velocity, and the desired velocity. Thus, Root motions only half effective during fall state.

It makes no sense for me, is it a bug? Probably would need to apply root motion to the “OldVelocity” before lerping the new and old velocity together. Or lerp without root motion THEN apply root motion, THEN multiply with delta time.
This is not a desired effect, and if it’s not a bug in the engine, can you help me overcome this problem?

Can I get an answer from epic developers? Its a big problem for me