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

Rotation relative to speed.

$
0
0
Hi,

My character send bullets, and I would like that their rotation to be relative to their speed, to go in the right direction.

I can make them spawn with the right angle, but then, the rotation doesn't get update.

I used this :
Code (JavaScript):
  1. function FixedUpdate(){
  2.  
  3.     angle = Mathf.Atan2(speed.x,speed.y)*Mathf.Rad2Deg;
  4.     print(angle);
  5.     rigidbody2D.rotation = (-angle);
  6.    
  7. }
I try to uncheck Fixed Angle, but it's not helping at all, anyone knows what to do? I've tried...

Rotation relative to speed.

Viewing all articles
Browse latest Browse all 1466670

Trending Articles