How can i use "look_at" properly?

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

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?

:bust_in_silhouette: Reply From: kidscancode

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.

1 Like
:bust_in_silhouette: Reply From: exuin

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

Excuse my ignorance, but how can i do that?

X | 2021-03-30 20:27

rotation -= PI/2

exuin | 2021-03-30 20:30