-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add warning about broken rotations to Transform::look_at()
docs
#6136
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right fix. IMO we should fix the underlying math instead; this is a nasty bug.
Nit: "parallel" is the spelling :)
a266ccf
to
99cd96f
Compare
No math to fix I'm afraid. There' is just no way to create a rotation from two parallel vectors.
Gah! I've made this mistake way to many times the last few weeks. Heck, I wrote it that way again typing the above, haha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this because of the Gimbal Locking problem?
Ugh, right. Can we return an |
It's similar. We need two direction vectors and them being parallel effectively removes one, like the axes in gimbal lock being parallel effectively removing one axis.
If you don't mind I add 62 instances of |
Hmm, right lol. Can we make a fallible variant which returns a Result then, and then point to it in these docs? |
Could use Vec3A::any_orthonormal_vector to generate an up direction if |
Linking a related issue: #3736 |
Unity somehow can calculate rotation so there must be a solution. Here is an example: transform.position = new Vector3(0.0f, 20.0f, 0.0f);
transform.LookAt(Vector3.zero, Vector3.up); And result:
|
Unity returns a partially randomized rotation instead. |
I prefer #7817: reducing mysterious footguns is better than documenting them. |
Add the following note to
Transform::look_at()
andTransform::looking_at()
: "Produces a broken rotation if the resulting forward direction is parralel withup
."