- Home /
How do I calculate current x-axis rotation of a configurable joint and set it as target position?
I am using configurable joint (conjo) to rotate a Rigidbody object, by setting conjo's drive mode to 'velocity.'
When I stop the rotating conjo object, by setting the target velocity to 0, the conjo is powerless, that is, other object, forces and gravity can still rotate it. I don't want this.
One strategy is to switch from 'velocity' drive mode to 'position' drive mode when stopping. This can be done by reading the last rotation along x and use that value as target position in conjo. The question is, how to I calculate the current x rotation of the conjo and apply it as its target position?
I tried the following:
if(stop) {
myConjo.targetRotation = Quaternion.Euler(this.transform.localRotation.eulerAngles.x, 0, 0);
}
However that little snippet does not work as I expected. Upon stopping the rotating object, the target rotation seem to go to another rotation that is different from this.transform.localRotation.eulerAngles.x.
Why not just use the entire rotation?
//check if needs local/world rotation
myConjo.targetRotation = this.transform.rotation;
Your answer
Follow this Question
Related Questions
How target rotation and target angular velocity work in configurable joint ? 1 Answer
Configurable Joint: Unable to keep distance the same 2 Answers
Constraint not totally working after manually overriding a joint rotation 0 Answers
If a joint has a Connected Body, does it ignore the Anchor position? 1 Answer
Configurable Joint just falls apart? 1 Answer