[HELP] Use Mathf.lerp to add an acceleration effect

HI, I felt that the rotation and thrust felt a little, brutal, so i did some searching and found the lerp, and smoothstep. Now from the docs, I was hoping one of those could be used to provide a more natural feeling thrust, and rotational movement, certainly for the rotation anyway.

Actual behaviour though is a hovering around and just above the min mark. Any ideas on this one? And when I say hovering, its a random number. I have tried using another variable other than time.delta time, but that just fixes my thrustThisFrame to the max value.

FYI: thrustDiv is currently in place of where time.deltatime has been sitting.

 private void Thrust()
{
    if (Input.GetKey(KeyCode.Space))
    {
        float thrustThisFrame = Mathf.SmoothStep(shipThrustMin, shipThrustMax, thrustDiv);
        rigidBody.AddRelativeForce(Vector3.up * thrustThisFrame);
        print(thrustThisFrame);
        if (!thrustSound.isPlaying)
        {
            thrustSound.Play();
        }
    }
    else
    {
        thrustSound.Stop();
    }
}

EDIT: More reading, I think the answer lays in SmoothDamp, but not certain…
EDIT2: This really is more for the rotation, not for thrust. However, it would be good to know how to make acceleration have a min and max value, reached in a linear manner over time for thrust!

Privacy & Terms