Trying to launch an arrow, and point the sprite in direction of travel/acceleration (2D)

I have looked at some different implementations, but the key difference seems to be that the existing examples all entail shooting an arrow/projectile from center of screen to the right. I want to shoot it up, and either to the left or to the right (if both is not possible for some reason then up and to the left).

The arrow should start off pointed in the direction it was shot, then it should rotate as it reaches its apex, and then point down if it begins to fall straight down obviously.

I am really struggling to come up with an intuitive way of handling this. But I do know that part of the issue is to do with the Math function Atan2 that is being used… Any way, here is the code I am currently using, which at least rotates the arrow in the Z axis, but it only sets the rotation when the arrow is launched, it doesn’t rotate the arrow as it keeps falling:

float angle = Mathf.Atan2(rb.velocity.y, -rb.velocity.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);

Changing rb.velocity.x to negative helped some what. Without that I can’t fire the projectile up and left at all.

It seems there should be a relatively easy way to implement this but I am just not figuring it out at the moment. Any help is much appreciated! Look at direction of travel!

No one has any ideas?

I was also thinking it could rotate purely based on acceleration in the Y axis. When acceleration in the Y axis hits 0, the projectile should face left (be flat) and then as negative Y acceleration begins increasing it should begin to gradually rotate until it is facing vertically down (depending on if it collides with anything incl. the ground before that point, obviously).

But how do I get acceleration values from my Rigidbody2D in Unity?

edit: Temporary workaround found.
An easily implemented temporary fix:

rb.AddTorque(12 * Time.deltaTime);

I think u can use transform.LookAt(…) function to get your desired direction. Or with quaternion.Lookrotation(…)

Hi, if you’re still on this i think you could use transform.LookAt() like this

void Update()
    Vector2 NextPosition = new Vector2(transform.position.x, transform.position.y) + 
    rigidbody2D.velocity * Time.deltaTime;

this should work for all directions don’t forget to replace "rigidbody2D with the rigid body 2d variable that you’re using
Note: I have not tested this in unity but i have done something similar in other engines