How do I make an arrow face the direction it travels in 2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TheWell

Hello, I have created an arrow sprite, but whenever it is fired from the enemy in a direction it faces the same way every time even if it is traveling left right up or down. The arrow always faces down, how can I make the orientation of the projectile match the direction of travel?

:bust_in_silhouette: Reply From: godotnoobperson

You can use this:

$Sprite.set_rotation(radians)

You can calculate the radians by using:

var radians
radians = atan(velocity.y/velocity.x)

I haven’t actually done this but I think it should work.