I noticed that when you move the Standard Assets FPS controller via the WSAD keys, the moment you let go of any key to stop it from moving it instantly halts any movement it was making.
I tried looking through the FirstPersonController.cs
script to find anything to do with smooth the transition between movement and suddenly stopping, but I couldn’t seem to find any. I saw the smoothing option for the camera movement but nothing to do with the physical movement.
Admittedly programming isn’t my strong suit. I would very much appreciate if anybody has a solution to smooth the sudden halting.
A simple solution would be to employ trapezoidal acceleration. It sounds scary but it’s not. Essentially you simply speed up or deaccelerate according to a maximum acceleration (change in velocity/speed), as opposed to always setting you actual speed to how fast you want to go.
In pseudocode form:
update() {
// If the difference is more than how much we can accel in a frame
if (actualSpeed < targetSpeed - maxAcceleration) actualSpeed += maxAcceleration;
// If the difference is more than how much we can deaccel in a frame
else if (actualSpeed > targetSpeed + maxDeacceleration) actualSpeed -= maxDeacceleration;
// else we're either on target or close enough (+/- maxAccel/maxDeaccel)
else actualSpeed = targetSpeed
}
Change the input from GetAxisRaw to GetAxis and use lerp to smooth it out.So when i let go of the keys it will have some momentum left and stop 0.1-1s later.Depending on lerp amount