- Home /
Question by
Vel_1828 · Jan 26, 2016 at 10:16 AM ·
c#2dphysicsprojectile
2D Arrow - face move direction?
Hey, a simple question. I'm trying to force my arrows to face the direction they are moving (so they make a nice parabolic move).
I have found this code which works, but when the projectile is moving to the .right, while my projectiles are moving .up - I guess it's a simple fix, but still I'm confused.
The Code:
var FaceDir : Vector3 = transform.position - previousPosition;
if(FaceDir != Vector3.zero)
{
var angle : float = Mathf.Atan2(FaceDir.y, FaceDir.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
}
Help...?
Comment