How do I make my sprite face the cursor?

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

I am trying to follow Top Down 2D Shooting in Godot tutorial to make my first game (I’ve already done the Getting Started in the docs). I ran into an issue right at the start - one line into coding. Tom says at 1:00 that the sprite should be facing right to make the rotation easier to work with. He recommends having the sprite’s rotation set to 90 then using the code:

func _process(delta):

His works, but mine is still 90 degrees off.
enter image description here

I figured out I can make it work by adding:

func _process(delta):
	rotation_degrees += 90

But, he explicitly tries to avoid this and I don’t want to start off on the wrong foot. Does anyone know what is happening here? I was surprised no one in the comments had this issue.

Here is my workspace:
enter image description here

:bust_in_silhouette: Reply From: skysphr

Godot (and pretty much any other software) considers angle 0 to be right-facing. Thus sprites that need to be rotated should be pointing right.

Oh! To double clarify, do you mean that the actual artwork itself needs to be pointed right? Is this something would do in Godot or would I need to rotate the asset in other software?

andre_angelo | 2021-10-25 20:40

Yes, that. Godot does not have image editing tools I’m afraid.

skysphr | 2021-10-25 22:36

:bust_in_silhouette: Reply From: totalgee

The easiest way to handle this is to insert the sprite beneath a parent node and set the sprite’s rotation to a fixed 90 degrees. Then do your navigation logic (e.g. look_at()) on the parent node. If you look in the video you reference, this is exactly the setup he has – a “Player” parent node (controlled by script), with the sprite under it, rotated at a fixed 90 degrees.

Completely makes sense. Thank you!

andre_angelo | 2021-10-26 16:28

1 Like