I'm using ConfigurableJoints for a mechanical rig. Some some joints have 1 DOF (angular X), some joints have 2 DOF (angular X,Y) and some joints have 3 DOF (angular X,Y,Z). I switch between velocity mode and position mode - velocity mode when I'm moving the joint, and position mode when the joint is at the desired position. This works as should.
Problem is when rotating the joint beyond 90 degrees around any axis. I "measure" the actual position (rotation) of the joint by using:
(Quaternion.Inverse(_ConnectedRigidBody.rotation) * _JointRigidBody.rotation).eulerAngles
If I for example rotate the X-axis of the joint, the measured x-value is fine up to 90 degrees. When the rotation > 90, the x-value starts to decrease, ie 89, 88, 87, 86 ... Same goes for rotations down to -90 degress - they are fine. But below -90 degrees, the measured value changes direction, ie -89, -88, -87, -86 ...
I have tried different ways of measuring the angle. I have re-inported my meshes with corrected pivot points, I have made children to the rotating parts trying to measure their rotation ... and I always get the same result - measured rotation values are fine up to 90 degrees (or down to -90) and then they change "direction".
I'm guessing there is something about the conversion from Quaternion to euler angles that is the problem, but I know too little about such conversions to figure out how to fix this.
Any idea of what I'm missing out on? Any advice is appreciated.
Thanx in advance ///JmD