Physics-based pawn suddenly stops when applying a gradually decreasing force

I have a physics-based pawn which uses AddForce for movement. In order to enforce a maximum speed on the pawn without making that limit obvious to the player, I check whether they’re applying thrust in the same direction as their movement, and if so, how close they are to maximum speed. Then I gradually decrease the force to 0 as they approach maximum speed.

This SHOULD result in a “soft cap” on speed that is gentle and non-disruptive. The problem is, we never even get to that point. As the pawn approaches maximum speed and the force decreases, it suddenly stops dead. There is no deceleration, the velocity just instantly becomes 0 in every direction.

Here’s the AddForce function, this is called per tick.

And this is the resulting logs. Note how there is no significant decelerating force, speed just becomes 0. (The force is only 1000 after the speed drops to 0, because at zero speed we get default force, while at max speed the force is greatly reduced)

Force=32.648 speed=998.25
Force=32.097 speed=998.801
Force=32.296 speed=999.354
Force=31.781 speed=999.869
Force=31.253 speed=1,000.397
Force=30.728 speed=1,000.921
Force=30.216 speed=1,001.433
Force=29.721 speed=1,001.929
Force=29.217 speed=1,002.432
Force=28.741 speed=1,002.908
Force=28.256 speed=1,003.393
Force=27.779 speed=1,003.87
Force=1,000 speed=0
Force=983.578 speed=16.422
Force=966.983 speed=33.017
Force=950.803 speed=49.197
Force=935.057 speed=64.943
Force=919.374 speed=80.626
Force=903.855 speed=96.145
Force=889.146 speed=110.854
1 Like