Player weird movement after implementing rotation

I use character controller for my player and at first it walks fine but after I make him rotate his body to face the direction he’s going to he starts walking and turning really weird

See the video here: Reddit - Dive into anything

public class PlayerMovement : MonoBehaviour{
    public static PlayerMovement Player;
   
    [SerializeField]
    public float _moveSpeed = 5f;
    [SerializeField]
    private float _gravity = 9.81f;
    public float rotationSpeed;

    private CharacterController controller;
    private Animator animator; //for later animation use
    // Start is called before the first frame update

   

    private void Awake(){
        Player = this;
    }

    void Start()
    {
        controller = GetComponent<CharacterController>();
        animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        playerMoves();
        PlayerData.Instance.Update();
        handleAnimation();
       

    }
    private void playerMoves()
    {
     



        float horizontalInput = Input.GetAxis("Horizontal");
        float verticalInput = Input.GetAxis("Vertical");
        Vector3 direction = new Vector3(horizontalInput, 0, verticalInput);
        direction.Normalize();

        direction.y -= _gravity;

        if (Input.GetKey(KeyCode.UpArrow)|| Input.GetKey(KeyCode.DownArrow)|| Input.GetKey(KeyCode.LeftArrow)|| Input.GetKey(KeyCode.RightArrow))
        {
            animator.SetBool("isWalking", true);
        }

        if (Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow) || Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow))
        {
            animator.SetBool("isWalking", false);
        }


        controller.Move(direction * Time.deltaTime * _moveSpeed); //multiple by Time.deltaTime so it moves once/second. In update it moves once every frame and frame/second can be very high
        if (direction!= Vector3.zero)
        {
            Quaternion toRotation = Quaternion.LookRotation(direction, Vector3.up);
            transform.rotation = Quaternion.RotateTowards(transform.rotation, toRotation, rotationSpeed * Time.deltaTime);
        }
    }

    void handleAnimation()
    {
        bool isWalking = animator.GetBool("isWalking");
        bool isRunning = animator.GetBool("isRunning");
        /*if (isMovementPressed)
        {
            animator.SetBool("isWalking", true);
        }*/

    }
   
}

Also somehow he’s not interacting with a door object with OnEnterTrigger. He just passed right through the door without being transported to another scene
The other door worked just fine but idk why this one doesn’t

Here is the script for the door object

public class EntranceToScene : MonoBehaviour
{
    public GameObject entrance;
    private string NameOfScene { get; set; } //name of the scene you want to go to

    public void OnTriggerEnter(Collider other)
    {
        //print(other.name);
        if (other.gameObject.tag.Equals("Player"))
        SceneCtrl.Instance.ChangeScene(SceneNameDefine.Scene.GhettoStreet); //how to go to 'nameOfScene' ???????????
    }

    //constructor for
    public EntranceToScene(GameObject entrance, string nameOfScene) //?????
    {
        this.entrance = entrance;
        this.NameOfScene = nameOfScene;
    }

}

Just from looking at your video, it looks like the “center” of your model, is not the center of your character. It looks like he’s rotation around a specific point, and that point is your origin for your GameObject (I’m assuming). You would probably just need to change your center to match up with that.

They currently looks matched? I mean the collider seems to fit the character perfectly

7599202--942964--a.jpg
7599202--942967--aa.jpg

Character controllers are designed to rotate around the Y axis. Your direction has gravity factored in, therefore will be pointing downwards. Your character controller will have to rotate its X and Z components, euler-wise, to match that.

Simply set your direction vector’s Y component to 0 before rotating. This way it won’t attempt to look up or down and go foobar.

Isn’t is already set to zero in line 43?

Look at line 46