0 votes

I have a simple arcade game and i would like the foe to look at the player. I used the "look_at" method and it works.

However, the part of the enemy that is looking at the player is his right side one and not his front or up one.

How can i fix that?

Godot version 3.2.3
in Engine by (73 points)

2 Answers

+1 vote
Best answer

Since 0 radians points to the right, subtract PI/2 radians from the angle you're looking at.

by (7,792 points)
selected by

Excuse my ignorance, but how can i do that?

rotation -= PI/2

+1 vote

In Godot (as in geometry), an angle of 0 degrees points along the x axis. look_at() will point your object's local x axis at the target.

The "solution" is to align your sprite so that it's pointing to the right when the rotation is 0.

by (21,313 points)
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 webmaster@godotengine.org with your username.