MOVE_Flying mode on CharacterMovementComponent has HUGE precision issues

(All of this is in C++)

I’ve been attempting to use the MOVE_Flying setting of the CharacterMovementComponent for my character, but the results have been… Frankly catastrophic.

First off, the braking: When moving, upon stopping to receive an input, the character will decelerate, then… stop decelerating.
So, for instance if we take the X axis of the velocity vector, we’ll reach somewhere near X=15.something, then it will just stay there… For a while.

After some time (multiple seconds, way more than it should given the braking values), it will suddenly jump to X=7.5 and stay there for a while. Then, after a very long time (up to a minute) the velocity.X will suddenly reach X=0.0.

Toying with it a bit more, I tried to change the vector directly to see if there is some kind of workaround to this issue… But this gets worse:

I tried binding a key to a custom action that, on press, substracts 3.25f to all three velocity axis. In other movement components, like for instance MOVE_Swimming, starting from a 0.0f velocity vector, you get… a -3.25f velocity vector, which is correct, since 0 - 3.25 = -3.25.

But in MOVE_Flying, substracting 3.25 on all three axis will give you that kind of result: X=-5.221 Y=-3.250 Z=-3.248

This is just crazy! Not only are there precision errors where they shouldn’t be (for a float), but the MONSTER GAP on the X axis just can’t be explained away by a mere precision error. The result on the X axis is nearly TWICE the expected substraction result! For the engine, 0 - 3.25 = -5.22, are you kidding me?? xD

So yeah, long story short, the MOVE_Flying mode for the CharacterMovementComponent is completely broken.

I did some digging, and the line 3332 in CharacterMovementComponent.cpp is what’s causing every problem I have encountered so far:

Velocity = (UpdatedComponent->GetComponentLocation() - OldLocation) / deltaTime;

Hello ,

There seem to be two main issues you’re reporting with the Flying mode for the CharacterMovementComponent. The first is that the velocity isn’t dropping as it should when input isn’t being given. This is governed by the “Braking Deceleration Flying” property. Its default is 0 and does result in very slow braking, usually bringing the velocity down to about 0.05 before it is culled and just brought to 0 from being truncated. Just by setting this value to 10, I experienced a reasonable deceleration rate. Can you try this?

As for the second problem, I’m not seeing the results you’re seeing. I created a C++ project based off the Third Person Template and then simply added a function to set the velocity to an amount equal to the current velocity -3.5 in all 3 axes. Doing this with no geometry in the way and printing the velocity on tick, I’m getting equal amounts in all 3 axes. Could there be a setting of some sort that is causing this to occur? I suggest comparing your character to one of the template ones to see if there may be some differences.

Apologies, I haven’t had time to try it out on my side and in a new project.

But if you were unable to reproduce, it means that the cause is on my side.

We haven’t heard from you in a while, . Are you still experiencing this issue? If so, was my last comment of any help? In the meantime, I’ll be marking this issue as resolved for tracking purposes.