I have a setup where I have a game object that has an empty game object as a child. The child is at a different world rotation from that parent. What I want to do is rotate the parent so that the child’s rotation matches a given rotation value (I get that rotation value from a different empty game object).
I think this can be done using the Quaternion math, but I have no idea how to do it. Any tips would be appreciated!
Thanks,
Zach
If Qc is the child’s world Quaternion, and Qto is the quaternion that you’re trying to match the child’s orientation to, and Qp is the parent’s current world quaternion, then…
Q’p = Qp x (Qc-1 x Qto)
Quaternion Qto; // Rotation to match the child to.
parent.rotation = parent.rotation * (child.Inverse * Qto);
Edit: I got it working. I think what I’m seeing is an affect of how I’m calculating the rotation to match.
Thanks for your help!!
Sorry to bring this thread back from the dead, but is child.Inverse the same as Qaternion.Inverse(child.transform.rotation)?