Velocity getting modified outside of NewFallVelocity?

I am overriding the function NewFallVelocity in CharacterMovementComponent to calculate a new fall direction based on the current floor the player resides.

NewFallVelocity(FVector OldVelocity, FVector OldAcceleration, float timeTick)

I figured that when falling, all velocity calculations would be handled in this function. But that does not always seem to be the case. When jumping if the players velocity is pointing in the negative world Z axis then the player will jump about twice as high. After some testing I determined that the OldVelocity parameter is not coming into the function exactly as I had returned it. Meaning somewhere velocity is getting modified outside this function. I linked a video that shows the issue.

In the start of the video the player is jumping in the positive world Z axis. Then walks to the negative world Z axis. Notice that when jumping in the negative world Z axis the player Jumps about twice as high.

I have created a temporary fix by no longer using the OldVelocity Parameter and storing the last fall velocity in another variable and using it on the next update. I would prefer to use the OldVelocity parameter if possible to keep this less hacky.

Is there a bool to disable velocity getting modified outside of the NewFallVelocity function when jumping in the negative Z axis? If not can this be added?

I currently have bLimitFallAccel to false and tried enabling/disabling bForceMaxAccel and bForceRegularVelocity.

Thanks for pointing this out. I see some code that could cause this behavior and I’ll follow up with the original author.

Frankly I’m surprised that you got things working in an inverted gravity situation :slight_smile: There are some assumptions on the code that gravity is always down.

Haha, where there’s a will, there’s a way:) Thank you for looking into it. This will be a great fix for anyone else attempting to do this in the future. After following up with the original author, will you let me know if a solution is planned to be added?

Yes I think I know what the fix is, I’m just waiting to hear back.

Hey Zak,
I was just wondering if you ever heard anything back?

Yes, there needs to be a code fix on our end to address the issue. The code makes a fair number of assumptions that gravity is always pointing down, and in this case it causes a very obvious issue.

Sounds great Zak! Thank you for taking the time to address the issue. I really appreciate it!