Player rotating towards direction of movement in 3D

So I have a Cube, in my project, and he currently moves and sprints perfectly, but I have tried for hours to make him rotate towards his current direction of movement, but I jus’t can’t make it happen :frowning:

Here is my code,

private Vector3 moveDirection = Vector3.zero;

public float gravity = 20.0F;
public float speed = 6.0F;
public float sprintSpeed = 8.0F;

void Update()
{
    CharacterController controller = GetComponent<CharacterController>();

    if (controller.isGrounded)
    {
        Move();
        Jump();
    }

    moveDirection.y -= gravity * Time.deltaTime;
    controller.Move(moveDirection * Time.deltaTime);
}

public void Jump()
{
    if (Input.GetButton("Jump"))
    {
        moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        moveDirection = transform.TransformDirection(moveDirection);

        moveDirection *= sprintSpeed;
    }
}

public void Move()
{

        moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        moveDirection = transform.TransformDirection(moveDirection);

        moveDirection *= speed;
}

I would appreciate help

also, I think it’s a problem with the Vector3, at the top (Vector3.zero)
I have no idea so thanksss :slight_smile:

Use Quaternion.RotateToward