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
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
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.