2D flying arrow.

Hello guys, I want to make realistic 2d flying arrow, but changing center of mass does not make arrow rotate (Z axis). Any suggestions? I want to make it only using 2d physics tools.

Hey,
The simplest solution (although not physically accurate) would be something like this:

public class Arrow : MonoBehaviour
{
    public Vector3 fv;

    void Start()
    {
        this.transform.Rotate(new Vector3(0, 0, 360.0f - Vector3.Angle(this.transform.right, fv.normalized)));
        this.rigidbody.AddForce(fv, ForceMode.Impulse);
    }

    void FixedUpdate()
    {
        this.transform.Rotate(new Vector3(0, 0, 360.0f - Vector3.Angle(this.transform.right, this.rigidbody.velocity.normalized)));
    }
}
1 Like

Is the arrow not rotating at all, or just not pointing directly in the direction it is flying?

may this link helpful

edit: Solved thanks to advice elsewhere:

   void RotationChangeWhileFlying()
    {
        currPoint = transform.position;

        //get the direction (from previous pos to current pos)
        currDir = prevPoint - currPoint;

         //normalize the direction
         currDir.Normalize();

        //get angle whose tan = y/x, and convert from rads to degrees
        float rotationZ = Mathf.Atan2(currDir.y, currDir.x) * Mathf.Rad2Deg;
        Vector3 Vzero = Vector3.zero;

        //rotate z based on angle above + an offset (currently 90)
        transform.rotation = Quaternion.Euler(0, 0, rotationZ + rotateOffset);

//store the current point as the old point for the next frame
        prevPoint = currPoint;
}

(I thought maybe it’d better to bump - at least at first - than create a whole new thread)

I’m trying to create the same affect as a 2D arrow pointing in the direction it’s moving but I can’t figure it out. Since it’s 2D I only want to rotate on the Z axis. I’ve seen information for 3D space but not really for 2D (like using Quaternion.LookRotation). I also saw about using rise/run (velocityY/velocityX) but I’m not sure how that fits in my case.

I guess I could affect the angularVelocity instead, I’m not sure if I should use the transform.rotation or that.

Basically it seems like, in-air, the projectile should rotate faster as it slows down/reaches the peak of the arc. I’d appreciate some help, thanks.