Comments and answers for "Why is this rotation not performed as expected?"
http://answers.unity.com/questions/1863575/why-is-this-rotation-not-performed-as-expected.html
The latest comments and answers for the question "Why is this rotation not performed as expected?"Comment by SilverLifeee on SilverLifeee's answer
http://answers.unity.com/comments/1863767/view.html
Thanks for the detailled response. I actually do use lookRotation now, but anyways I want to know why my described approach does not work. To answer your question about my goal: Imagin a sphere with its position at the world origin. (lets name it earth). <br>Now I have a coordinate system which is always perpendicular to the earth surface (lets call it perpendicularPlane). The camera is in another coordinate system, which hast the same orientation as the perpendicularPlane. Within the perpendicularPlane-coordinate-system , I have a lot of objects, which should always have the same orientation as the camera but with the constraint that every roll-angle of the cam (means z-rotation) needs to be reverted (that means, every object´s x-axis is perpendicular to the perpendicularPlane). <br>So what I was thinking , if I first set the object´s rotation equal to the one of the camera and afterwards rotate them back around their forward vector, I should be able to revert the unwanted rotation. <br> This actually works, but only with Approach1, where I set the z-rotation in inspector to zero, but with Approach2 this does not work. And I would really like to know, why this does not work because I think this knowledge is really important for further developement with unity.Thu, 30 Sep 2021 10:20:21 GMTSilverLifeeeAnswer by Bunny83
http://answers.unity.com/answers/1863747/view.html
You have the wrong idea of quaternions ^^. A quaternion is always a relative rotation around a single axis. To represent an absolute orientation with a quaternion (which we do with transform.rotation) it has to represent a rotation that brings your coordinate system from the initial orientation to the target rotation. Imagine a simple case where the camera is first looking straight without any rotation. If you rotate the camera 90° to the right it means it's forward axis will change from (0,0,1) to (1,0,0) since the camera is now facing to the right. However which rotation axis gets you there? Exactly, a rotation around the y axis. That would be the axis you have to specify for AngleAxis.
<br>
Most prople make the mistake of still thinking in terms of euler angles. Euler angles are 3 seperate rotations around 3 axis performed one after the other in a particular order. A quaternion represents the combined rotation as one single rotation. The actual rotation axis of the localRotation could be any uninuitive axis since it essentially has to rotate your object within the local space of the parent from the not rotated state to the target rotation with a single rotation axis.
<br>
It's actually an amazing fact that you can rotate toany orientation in space by just a single axis rotation. It's difficult to tell whats your exact goal and why you need this specific setup. Why don't you use LookRotation? Keep in mind that LookRotation also works for local rotations as long as the direction vectors you use are in that local space the rotation lives in. That means the parent coordinate space.
<br>
This question somehow reminds me of [this question we just had about 2 weeks ago][1]. A different case but it also has to do with manipulating the child rotation so it aligns with a worldspace orientation, though with an offset.
[1]: https://answers.unity.com/questions/1861700/quaternion-inverses.htmlThu, 30 Sep 2021 08:45:46 GMTBunny83Comment by SilverLifeee on SilverLifeee's comment
http://answers.unity.com/comments/1863727/view.html
The Rotation is different between two approaches, simply because somehow it does not rotate the object around z-axis.Thu, 30 Sep 2021 05:56:01 GMTSilverLifeeeComment by bdubbert
http://answers.unity.com/comments/1863618/view.html
When you say the rotation is complete nonsense, is the actual orientation of the object different between the two approaches? Or are the numbers showing up in the inspector just different?Wed, 29 Sep 2021 15:34:50 GMTbdubbert