Make Quaternion.Slerp Less Jittery

Hello, I have created a simple state machine for a 3rd person camera system. In my state machine I have different actions the player can do, WalkLeft, WalkRight, Forward, etc. In my WalkingLeft state I have tried to set up a nice rotation for the player. However the rotation is very jittery, within a 30 degree angle.

Here is my code for the walkingleft state.

    void WalkingLeft()
    {
        //transform.Rotate(0, 270, 0);
        //Debug.Log(transform.rotation);
        //Debug.Log(transform.eulerAngles.y);

        Quaternion target = Quaternion.Euler(transform.rotation.eulerAngles.x, (transform.rotation.eulerAngles.y + 270.0f), transform.rotation.eulerAngles.z);

        transform.rotation = Quaternion.Slerp(transform.rotation, target, rotateSpeed * Time.deltaTime);

        Debug.Log(Quaternion.Angle(transform.rotation, target));
        
        anim.CrossFade("Walking");
    }

“Left” must be relative to the player, I think my issue is somewhere in setting the target but I’m not sure what exactly to change.

The goal of the smooth rotation is to make it where the character doesn’t instantly face left or right. The character should rotate to what is right and left.

Thanks for your time.

If only problem is jittering, Slerp could be the reason. Because your transform.rotation and target rotation is constantly changing. You need to hold your rotation before turning to left:

private Quaternion rotationBeforeLeft;
   void WalkingLeft()
     {
         //transform.Rotate(0, 270, 0);
         //Debug.Log(transform.rotation);
         //Debug.Log(transform.eulerAngles.y);
 
         Quaternion target = target = Quaternion.Euler(rotationBeforeLeft.eulerAngles.x, (rotationBeforeLefty + 270.0f), rotationBeforeLeft.eulerAngles.z);
 
         transform.rotation = Quaternion.Slerp(rotationBeforeLeft, target, rotateSpeed * Time.deltaTime);
 
         Debug.Log(Quaternion.Angle(transform.rotation, target));
         
         anim.CrossFade("Walking");
     }