0 votes

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):
    look_at(get_global_mouse_position())

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):
    look_at(get_global_mouse_position())
    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

Godot version 3.3
in Engine by (17 points)

2 Answers

+2 votes
Best answer

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.

by (54 points)
selected by

Completely makes sense. Thank you!

+1 vote

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.

by (1,305 points)

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?

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.