Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | cgardner | |
Old Version | Published before Godot 3 was released. |
Hello!
I’m trying to script a simple guard for a 3rd-person game, and I would like the guard to turn to face the player when entering his FOV (a collision box).
However, this code:
look_at(playerref.get_transform().origin, Vector3(0,1,0))
does this:
The small character is the player, the large one is a guard (same model, placeholder assets so the scales are goofed up).
Why is the guard model rotating in x-axis as well as y-axis?
I thought that look_at() was supposed to rotate around the “up” axis given as input? Is there a way to use look_at() while only rotating around y axis? Also, what is the “forward” direction for a character? You can see the model on the right is facing away, is -z the “forward” direction?
FWIW I’ve read through this article on motion and rotation, but it seems to just say “use look_at().”
Thank you for your help!!!