This is one of those threads I'm always really reluctant to post because I'll end up feeling really silly if I've got it wrong... but it's worth it just in case I can save someone else a week's worth of nightmarish debugging.
OK, so the Unity
docs for the Quaternion * operator say:
Quaternion.operator *
static operator * (lhs : Quaternion, rhs : Quaternion) : Quaternion
Description
Combines rotations lhs and rhs.
Rotating a point first with lhs and then with rhs is the same as rotating the point by the combined rotation. Note that rotations are not commutative: lhs * rhs does not equal to rhs * lhs.
I'm writing a fairly complicated game at the moment with lots of 3D transforms in it and having spent a week failing to get hinges working properly I eventually get a little suspicious and run this:
print("Test 1 - " + (rot1 * Vector3.up));
print("Test 2 - " + (rot2 * Vector3.up));
print("Test 3 - " + ((rot1 * rot2) * Vector3.up));
print("Test 4 - " + (rot1 * (rot2 * Vector3.up)));
print("Test 5 - " + (rot2 * (rot1 * Vector3.up)));
And the output looks like this:
Test 1 - (0.0, 1.0, 0.0)
Test 2 - (0.5, 0.8, -0.2)
Test 3 - (-0.2, 0.8, -0.5)
Test 4 - (-0.2, 0.8, -0.5)
Test 5 - (0.5, 0.8, -0.2)
So do I need more caffeine this morning, or is that actually the opposite of what the docs say?
