-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
look_at_from_position: Up vector and direction between node origin and target are aligned, look_at() failed. #53793
Comments
This is down to maths - it is because if your up vector is up, and you want to look up, you still have an undefined rotation around the up axis. Not only that, as you approach the up axis, you will immediately swap from a defined rotation to an undefined rotation, and you will also get some randomisation going on of the rotation due to floating point error. How you should best handle this depends on the case. Godot could have gdscript return some standard rotation I guess, but it would usually lead to other visual errors because the user is not handling the situation properly. What you are probably imagining is if you were told right now to look up, you would look up but your yaw would be the same as your previous yaw. But the |
If you tell me to |
It would be nice if there was such a function that assumes the same yaw, or such like alternative. The majority of use cases for "look_at" and "look_at_from_position" use the default up vector (Vector3.UP). When calling "look_at" every physics tick, to avoid the error it's annoying to need a check in GDScript (like 'not up.cross(-target.normalized()).is_zero_approx()') that is already done by the function itself in c++ (see note 1. below), particularly for performance reasons, since I'm happy just keeping the same rotation that tick. Is this not a common use case? Note 1.: Line 1047 in d93b66a
Line 821 in d93b66a
Related issue as mentioned by lawnjelly: #57457 |
A more intuitive alternative: look_at_direction |
Godot version
v3.4.beta4.official [6a058cb]
System information
Windows 10, Nvidia GTX 750Ti
Issue description
I would like to know why the up vector and direction between node origin and target being aligned is considered an error and why I have to add checks to make sure its directly not Vector3.Up and Vector3.Down. This seriously does not make since to me at all. Shouldn't it just be the default rotation of being upwards or downwards? If there is some complex reason why this is like this, can it have some sort of documentation? Thanks!
Steps to reproduce
Note that this is is just a example of a line that would cause the error:
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: