Adding/Subtracting Rotation Data
Rotations are pretty nasty. I've come to my wits end. I'll do my best to make this very simple.
Here is what I am trying to do
I have two skeletons with the same shape and same pose, but because of issues between Maya and Unity's rotation order, the rotations on the joints are not the same. I have an animation on one model and want to use LateUpdate to match the rotation between the joints. Seems simple enough.
First problem and how it can be solved
Since the resting rotations are different, I simply cannot set the rotations to each other. If I could, there wouldn't even be a need for a LateUpdate setter. Logically the solution is easy. Find the difference between Animated Model A's resting rotation and animated rotation. I can find the difference by subtracting the two. By subtracting the two we find out that during animation, JointA was rotated 3 degrees on an axis. We simply apply that rotation to Model B's jointA.
Problems
It doesn't work. There are so many reasons it doesn't work but I simply don't understand what is wrong. If anyone knows a better way to do this, I suppose that would be what I am asking.
Here is the code for reference.
var SourceObjects : GameObject[];
var SourceRest : GameObject[];
var DestinationObjects : GameObject[];
function LateUpdate (){
for (var i : int = 0; i < SourceObjects.length; i++){
DestinationObjects[i].transform.rotation = (SourceObjects[i].transform.rotation * Quaternion.Inverse(SourceRest[i].transform.rotation));
}
}
}
I'm using Quaternion.Inverse because as far as I am aware that is the only way to subtract rotations. Please correct me if I am wrong but I believe the documentation confirms that.
Thank you to anyone with any ideas whatsoever. It is greatly appreciated.
Your answer
![](https://koobas.hobune.stream/wayback/20220612184415im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Clamping a Quaternion Euler 0 Answers
Why Quaternion.Euler can't rotate 360 Degrees 0 Answers
Child Object Rotation interpolation problem, 0 Answers
Something seriously weird is going on with my transform.eulerAngles 0 Answers
Rotating Vector3, linecast 1 Answer