- Home /
rotation relative to a transform
Hi,
I am lost with how to calculate the rotation relative to a transform.
While InverseTransformPoint works well to calculate a position relative to a transform, how do achieve the same process but for rotation?
in short:
I would like to know modelB rotation relative to modelA transform.
I tried InverseTransformDirection but it doesn't seem to work for me. How could I then express a rotation as a direction and vice-versa?
EDIT: let me rephrase: how do I compute manually the localRotation value when the model is actually not parented? That is, what is the localrotation of modelB as if it was parented to modelA? I am not trying to modify the actual localrotation of modelB, I just need to know it to inject it in the rotationTarget of a joint.
thanks for your help,
Jean
Answer by Aubrey Hesselgren · Aug 18, 2010 at 05:01 PM
To construct a Quaternion rotation from one orientation to another, you could try:
Quaternion rotationDelta = Quaternion.FromToRotation(modelA.transform.forward, modelB.transform.forward);
This means that if you multiplied modelA.transform.rotation by rotationDelta, you'd end up "turning" modelA's orientation to face the same direction as modelB's orientation. Hope that makes sense (and I hope I didn't get it wrong).
Basically, once you get that quaternion rotation is all about relativism, it kind of starts to make sense.
ok, I think I understand what you mean, I am not able just yet to make it work, but trying.
Your answer
Follow this Question
Related Questions
C#:"w" and "s" switch roles w/ transform.rotation of 180 0 Answers
Rotate the player toward a direction 0 Answers
Problem with Shooting Accuracy 0 Answers
Bouncing Ball Problem( bounces vertically forever) 1 Answer
[JS] transform.rotation not working 1 Answer