I’m trying to rotate a joint representing a right arm which starts in an orientation straightened to the right.
When I click on the joint, the transform says it was rotated Z -90. The green arrow points towards the right. The blue arrow points forward (same direction player is facing). The red arrow points down.
I want to re-orient this such that “forward” is considered the hand’s direction (right), and “up” is towards the sky.
According to ConfigurableJointExtensions by Michael Stevenson, a ConfigurableJoint’s “axis” represents “right”, and “secondaryaxis” represents “up”. Note there is literally no other documentation about exactly where these axes point, not even by Unity, which only says they form the coordinate system. So I have no other source of truth to go by when claiming that “axis” is “right” and “secondaryaxis” is “up”.
Assuming “axis” is “right” and “secondaryaxis” is “up”, I therefore set “axis” to (0, 0, -1) which points in the backward direction of the player and is what I want “right” to be for the joint. I then set “secondaryaxis” to (-1, 0, 0) which (after considering the arm’s rotation) points in the upward direction of the player, which is the “up” I want for the joint.
Now if I set target rotation around Y to 45, it rotates counter-clockwise. But why? Wouldn’t you expect it to rotate clockwise? I assume in Unity’s left-handed coordinate system, a “positive” rotation around an axis is clockwise according to the left hand rule. I confirmed this when setting a quaternion to Quaternion.FromToRotation(Vector3.forward, Vector3.up). Debug statement showed this was represented by 90 degree rotation around (-1, 0, 0), aka euler angles (270, 0, 0).