|
|
|
 |
Reply From: |
Zylann |
When it comes to axes and what is considered “forward”, Godot follows OpenGL convention.
look_at()
makes the given spatial node look at the target using negative Z.
Your eye is not setup to look at -Z, which is why you probably added the following rotate_x()
. However it seems like it’s the wrong axis, or wrong rotation. Besides, rotate_x
rotates the local transform around the global X axis (confusing!).
You may want to try rotate_object_local
instead.
I don’t know how you setup your eye, so I don’t know which axis to tell you to change, but I did remake myself a test scene with an eye looking like your game. I made the eye look at +X, so to make it look at -Z, it needed to rotate by -90 degrees around Y, and this worked:
_eye.look_at(_player.translation, Vector3(0,1,0))
_eye.rotate_object_local(Vector3(0, 1, 0), -PI / 2.0)
However it would be easier if you just made your eye look at -Z 
Looks like the rotate_object_local()
solved the problem. My function looks like this now:
func eye_track(delta):
eyeball.look_at(look_target, Vector3(0, 1, 0))
eyeball.rotate_object_local(Vector3(1,0,0), -PI/2)
And the eye finally seems to follow the player without these strange distortions on the sides and below.
Thank you!
This rotate_object_local
example sometimes gives an invalid result. I decided to check how a default CSGCylinder is oriented on many iterations. Around 1/20 of those are incorrect. Test project on GitHub.