# How to make an arrow fly realistically.

Hey guys!
Now I’ve seen a bunch of other questions and topics like this on the forums, but none of them work for what I am needing. Basically I wan’t an arrow that is shot from a bow to move realistically (The tip of the arrow points in the way it’s traveling.) but I can only find code that works for an only-right bow. Here’s a picture of what I’m talking about:

And here’s the code I’m using:
EDIT: Do NOT use LerpAngle for functions like this. It makes the Rotation go from 360 degrees back to 0 instead of rotating it properly.

``````Vector3 velocity = rigidbody2d.velocity;
float angle = Mathf.Atan2(velocity.y, velocity.x) * Mathf.Rad2Deg;
Quaternion tempRotation = Quaternion.AngleAxis(angle, Vector3.forward);
Quaternion newRotation = gameobejct.transform.rotation;

newRotation.x = Mathf.LerpAngle(newRotation.x, tempRotation.x, speed);
newRotation.y = Mathf.LerpAngle(newRotation.y, tempRotation.y, speed);
newRotation.z = Mathf.LerpAngle(newRotation.z, tempRotation.z, speed);
newRotation.w = Mathf.LerpAngle(newRotation.w, tempRotation.w, speed);
``````

Thanks!

Uhuh! I’ve found a solution that works perfectly! I did a little more research and found this: Rotate towards velocity (2D) - Unity Answers

Basically this code should work if your arrow is facing right at the rotation (0, 0, 0,).

``````Vector2 v = rigidbody2D.velocity;
angle = Mathf.Atan2(v.y, v.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
``````

Manipulating the values of quaterions individually is a very, very, very, very, very bad idea, unless you perfectly know what you are doing (and it’s not the case obviously).

Unity has a built-il method to do a Slerp between two quaternions simply called Quaternion.Lerp

Realistic rotation of flying arrow? - Unity Answers maybe could more help