Rigidbody Third Person Controller Tilt

Hey! I’m making a Third Person Controller with rigidbody and I discovered that when I jump or just fall the character tilts weirdly Here is the player movement script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
    [SerializeField] Transform cameraFollow;
    [SerializeField] LayerMask groundLayer;
    [SerializeField] Animator animator;
    [SerializeField] string speedAnimatorParamName;
    private Rigidbody rb;
    private Vector3 movementInput;
    private bool pressedJump, pressedShift, isGrounded;
    private float horizontalInput, forwardInput;

    [SerializeField] float speed;
    [SerializeField] float jumpingHeight;
    [SerializeField] float runningMultiplier;
    [SerializeField] float rotationSpeed;
    [SerializeField] float groundCheckRayLength;
    [SerializeField] float animationLerpingSpeed;

    private void Start()
        rb = GetComponent<Rigidbody>();

    private void Update()

    void FixedUpdate()
        // set animation speed parameter
        animator.SetFloat(speedAnimatorParamName, Mathf.Lerp(animator.GetFloat(speedAnimatorParamName), movementInput.magnitude, Time.fixedDeltaTime * animationLerpingSpeed));

    private void HandleJump()
        isGrounded = Physics.Raycast(transform.position, Vector2.down, groundCheckRayLength, groundLayer);
        if (pressedJump && isGrounded)
            rb.AddForce(Vector3.up * jumpingHeight, ForceMode.Impulse);

    private void MovePlayer()
        // set player velocity based on the speed
        rb.velocity = new Vector3(movementInput.x * speed, rb.velocity.y, movementInput.z * speed);
        // set player rotation velocity by rigidbody to 0
        rb.angularVelocity = Vector3.zero;

    private void RotatePlayerBasedOnMoveDirection()
        if (movementInput.magnitude <= 0) return; // the player not pressing any movement input and the player is not moving
        // Calculate the desired rotation to face the rb.velocity direction
        Quaternion desiredRotation = Quaternion.LookRotation(rb.velocity.normalized, Vector3.up);

        // Interpolate smoothly between the current rotation and the desired rotation
        transform.rotation = Quaternion.Slerp(transform.rotation, desiredRotation, Time.deltaTime * rotationSpeed);

    private void CalculateMovementDirection()
        // Calculate the forward direction of the camera
        Vector3 cameraForward = cameraFollow.forward;
        cameraForward.y = 0f; // Ignore the camera's Y rotation
        // Calculate the movement input relative to the camera's forward direction
        movementInput = (cameraForward.normalized * forwardInput + cameraFollow.right.normalized * horizontalInput) * (pressedShift ? runningMultiplier : 1f);

    private void GetInput()
        horizontalInput = Input.GetAxisRaw("Horizontal");
        forwardInput = Input.GetAxisRaw("Vertical");
        pressedShift = Input.GetKey(KeyCode.LeftShift);
        pressedJump = Input.GetKey(KeyCode.Space);

    private void OnDrawGizmosSelected()
        Gizmos.DrawLine(transform.position, transform.position + Vector3.down * groundCheckRayLength);  

Thanks for anyone who can help! :smiley: