Hi Everyone,
I am having problems computing the targetrotation of a configurable joint.
START EDIT You can find the application resulting from this question here
http://www.fabrejean.net/projects/excavator
END EDIT
background: I am swapping the JointDriveMode from velocity to position drive when the targetAngularVelocity magnitude is 0. So I need to compute out of the blue the targetRotation of a joint. I do not know nor can maintain a variable holding this variable since it was driven using velocity and the joint unfortunatly can not be queried for this. Also, the joint is not configured in worldspace.
for convenience and to avoid misinterpretations, I have added the sources of this specific problem online and with a webplayer version:
http://www.fabrejean.net/projects/unity/velpos.html
I am using currently:
GetComponent(ConfigurableJoint).targetRotation
= Quaternion.Euler(joint.connectedBody.transform.localEulerAngles)
This is not working when the rigidbody implementing the joint is itself constraint by another configurable joint. Basically it doesn't work with a chain of joints. it jumps to weird angles instead. While this works very well when the rigidbody holding the joint is not attached to anything. I could be wrong in this assumption, but that's what I am experiencing so far.
So:
Is there actually a way to switch JointDriveMode from velocity to position and have the joint stay in its current position? Currently if you switch it jumps back to the default values.
Is there a proper way to find out about the targetRotation accuratly in all situations?
Thanks for your help. I can provide a small example if someone is interested to get a proper working case of this.
Jean,