How to smoothen Pitch, Yaw, Roll?

Hi there,

I have a small script for spaceship. All movements are working fine, but it’s not really smooth. I would like my movement a bit ‘bouncy’, that the spaceship is not stopping rotation instantly when releasing controller.

Any suggestions how to fix this? I’ve read about Lerp or addforce options. But I don’t understand how to use it in my setup.

Snippet of my code:

    void Update()
    {
        // get input movement
        roll = Input.GetAxis("Roll") * (Time.fixedDeltaTime * RotationSpeed);
        pitch = Input.GetAxis("Pitch") * (Time.fixedDeltaTime * RotationSpeed);
        yaw = Input.GetAxis("Yaw") * (Time.fixedDeltaTime * RotationSpeed);
    }
    void FixedUpdate()
    {
        Quaternion AddRot = Quaternion.identity;

        AddRot.eulerAngles = new Vector3(-pitch, yaw, -roll);
        rigidbody.rotation *= AddRot;
}

Thanks in advance!!

Here’s a cascade of posts containing various infos. Each approach will have a different “feel” to the controls.

Lerping to smooth things out:

In the case of input smoothing (implementing your own input filtering):

Smoothing movement between discrete values:

The code: Smooth movement - Pastebin.com

Try this, maybe:

    public float blend = 0.9f;

    float oldRoll;

    void Update()
    {
        // get input movement
        roll = Input.GetAxis("Roll") * (Time.fixedDeltaTime * RotationSpeed);
        roll = blend * roll + (1 - blend) * oldRoll;
        oldRoll = roll;
    }

Thanks guys! Will try this. I’ll let you know…

Hi guys, your posts lead me to the right direction. Thanks again.

You’re welcome! Glad you got something out of it.