I got a 2D Player object. This object always looks towards his moving direction with this code:
For the most part this rb.velocity returns the right direction. But when the player collides with another object the direction isnt as accurate as it should be. On the screenshot u can see in which direction the player is moving...
Rigidbody2d.velocity not correct
Code (CSharp):
- float direction = Mathf.Atan2(rb.velocity.y, rb.velocity.x)* Mathf.Rad2Deg
- transform.rotation = Quaternion.AngleAxis(direction , Vector3.forward);
Rigidbody2d.velocity not correct