Getting the current angle/s of a CharacterJoint

Hello,

I have not found an answer to this and related postings, so I would really appreciate a clear answer (as I’m sure others will too).

I am using CharacterJoints with a ragdoll, and want to implement a controller to bring the ragdoll ‘to life’, i.e. moving the joints about.

I would like to know:

How can I obtain the current angle of rotation of the joint at runtime? Can someone clarify exactly how this works in unity with a CharacterJoint, bearing in mind that it has the potential to rotate around 3 axes?
e.g. why is there not a joint.angle1/angle2/angle3 method or property?

I’m sure there is a sensible answer, and I admit I am slightly confused between local/world coordinates etc. If there is no direct way, what exactly is the way to work it out?

FYI, my controller for each joint will take 1, 2 or 3 axes (since I think I am aiming for twist, swing1, swing2 axes) and output a value from 0…1 for each, which represents the desired angle of the joint in that axis.
My goal is therefore to take this 0…1 value and first map it to a desired angle (in degrees) from the appropriate minimum and maximum range (exactly how to obtain this, versus just using the adjusted parameters in the Inspector, I am also not clear on). To compute the torques required to move the joint to the desiredAngle, I need to know what the current angle is (for each axis), and it is this which I cannot do.

Thank you very much indeed for any suggestions.
Greg

As you say, there is no angle property that just lets you read the angle of the joint directly. If the attachment positions of the joints are arranged in a consistent way, you might be able to calculate the angle using Vector3.Angle. Say if you have it arranged so the joint’s length is always along the Y axis, you could get the transforms of the parent and child object and use something like:-

angle = Vector3.Angle(par.transform.up, ch.tranform.up);

Not ideal, but it might solve your problem.

Thank you but as you have suggested this doesn’t sound like a very satisfactory option, surely there is a more standard/straightforward way to do it?

I’m fairly sure there isn’t an easier way, but you could try sending an e-mail to support (support@unity3d.com).

Okay I will do but in the mean time surely someone out there has tackled this problem before??

Thank you again for any further help.