I have a 2D GameObject that changes velocity at each game loop iteration. I want to also update its rotation, simply heading the velocity vector. I’m currently using
transform.rotation = Quaternion.Euler(0, 0, Mathf.Asin(rigidbody2D.velocity.y / rigidbody2D.velocity.magnitude) * Mathf.Rad2Deg);
However, this rotates the object only between 90-0, and 270-0. When the angle exceeds 90, it automatically changes to 270 and keeps on increasing from there.
I’ve tried almost all of the suggestions here but none of them solved my problem. Any help would be appreciated.