Rotate a 2d object based on velocity

Hello everyone I am pretty new to using unity and making games,

I am creating a worms type game and I have an object being shot based on the arrow angle.

alt text

Once the object is shot I want it to be rotated to look real as if the tip of the object is going down first. How could I go about doing this? I tried using this code once the object’s Y velocity was going negative.

public class AirStrike : MonoBehaviour
{
    public float spellSpeed = 8f;
    public Vector3 targetAngle = new Vector3(0, 0, -121);

    private Vector3 currentAngle;
    // Start is called before the first frame update
    void Start()
    {
        currentAngle = transform.eulerAngles;
    }

    // Update is called once per frame
    void Update()
    {
        Debug.Log(GetComponent<Rigidbody2D>().velocity.y);
        if (GetComponent<Rigidbody2D>().velocity.y <= 0)
        {
            currentAngle = new Vector3(
                Mathf.LerpAngle(currentAngle.x, targetAngle.x, Time.deltaTime),  
                Mathf.LerpAngle(currentAngle.y, targetAngle.y, Time.deltaTime),  
                Mathf.LerpAngle(currentAngle.z, targetAngle.z, Time.deltaTime)
            );
            transform.eulerAngles = currentAngle;
        }
    }

}

Thanks for your help in advance :slight_smile:

Try to use “Rigidbody.AddTorque()” . It might solve the problem :slight_smile: