- Home /
Reverse local rotation applied to child
I have a rotation that is applied to the gameobject "parent" as follows:
parent.localRotation = NewParentOrientation;
unfortunately that transformation is applied to its "child" node as well, so i want to reverse/cancel the transformation for the child.
child.localRotation*= InverseRotation;
Unfortunately, i dont know how to find InverseRotation quaternion.
Input (known data):
Quaternion OldParentOrientation;
Quaternion NewParentOrientation;
Output:
Quaternion InverseRotation; //Rotation needed To Move From Old To New Orientation;
Problem: NewParentOrientation is a "Orientation" quaternion (assigned by = not *= to parent). Quaternion.Inverse(rotation) only works on "Rotation" quaternions not "Orientation" ones.
If you could find a "Rotation" quaternion that manages to move parent from OldParentOrientation to NewParentOrientation then my problem would be solved. I could easily reverse it with Quaternion.Inverse then.
You may have found a smarter way to cancel the rotation to the child. Please note the following limitation: you cannot alter the hierarchy. child must be childof parent.
Answer by IvovdMarel · Jun 27, 2017 at 11:16 AM
You can store the child's global rotation into a temporary variable.
Quaternion childRotation = child.rotation;
parent.localRotation = newParentOrientation;
child.rotation = childRotation;
Your answer
![](https://koobas.hobune.stream/wayback/20220612124958im_/https://answers.unity.com/themes/thub/images/avi.jpg)