How to rotate a gameobject based on the direction it is travelling in 2d?

Hi.

I am trying to make a square rotate it towards the direction it is travelling. This is the code I am using but it rotates it on the x - axis: transform.rotation = Quaternion.LookRotation(rb.velocity);
Plz give me a solution :slight_smile:

This is the code I use when moving a character based on the vector2 input from the input system.

private Vector2 movement;

transform.rotation = Quaternion.LookRotation(Vector3.back,movement);

This allows me to rotate on the z axis so my sprite doesn’t disappear.

I have a full write up on using this for a top down movement script on my website.