Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Rigidbody2d.velocity not correct

$
0
0
I got a 2D Player object. This object always looks towards his moving direction with this code:

Code (CSharp):
  1. float direction = Mathf.Atan2(rb.velocity.y, rb.velocity.x)* Mathf.Rad2Deg
  2. transform.rotation = Quaternion.AngleAxis(direction , Vector3.forward);
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

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>