Make an object or character face the direction it is moving?

Hello - I am trying to make my character face the direction they are moving on a grid-based game. I have this code so far which doesn’t quite work.

private void Update()
    {

        //Face the direction the unit is moving
        Vector3 dir = Vector3.zero;

        transform.rotation = Quaternion.LookRotation(dir);

        if (dir != Vector3.zero)
        {
            transform.rotation = Quaternion.Slerp(
                transform.rotation,
                Quaternion.LookRotation(dir),
                Time.deltaTime * 1.0f
            );
        }


        if (!Unit.isMoving)
        {
            anim.SetBool("IsMoving", false);
        } else {
            anim.Play("Walk");
            anim.SetBool("IsMoving", true);
        }

    }

My thought was to try to find the velocity and then rotate based on that. What am I doing wrong?

You’re using Slerp incorrectly:
https://chicounity3d.wordpress.com/2014/05/23/how-to-lerp-like-a-pro/

If you want to rotate the transform over time, use Quaternion.RotateTowards instead.

For anyone wondering, the answer was simple and I feel stupid. Thank you to xVergilx for starting me down the right path:

 private Vector3 prevPosition;

    void Start()
    {
        prevPosition = transform.position;
    }

    private void Update()
    {
        // Calculate position change between frames
        Vector3 deltaPosition = transform.position - prevPosition;

       
        if (deltaPosition != Vector3.zero)
        {
            transform.rotation = Quaternion.RotateTowards(
                transform.rotation,
                Quaternion.LookRotation(deltaPosition),
                Time.deltaTime * 60.0f
            );
        }

        prevPosition = transform.position;
}