(Bug) Disabled configurable joints changing rotation after being enabled

Hello, I have an issue with configurable joints that I’ve had a year ago already. I deactivate the parent of a ragdoll when the player is far so that the performance is better. But when it gets re enabled, the joints bug out / rotates past their limits (not sure, but it rotates automatically for example face turns upside down etc.).

Things I’ve verified:
*Colliders have nothing to do with it
*Still happens with Angular limits free or limited
*Rigidbody doesn’t have anything to do with it
*Even if I set the rigidbody to isKinematic then disable the joints.gameobject or even the parent itself and re enable them then set the isKinematic to false, it still happens
*Tried disabling Autoconfigure
*Tried changing Rotation drive mode
*Projection mode
*Configured in world space , swap bodies, enable collision, pre processing
*I’ve also tried storing rotation variables of the anchor, transform.rotation, target rotation and restoring then using OnEnable
*Tried setting the velocity to zero

Here is a video if you’d like to see what’s happening

If you can’t solve it maybe you know of an alternative solution to save performance for having a ragdoll that is far from a player (setting it to isKinematic = true triggers the bug too)

Thanks a lot!

I’ve had similar problems before, and they’re related with the “rest” pose of the joint. When the joint is created, it takes the current position and rotation with respect to the rigidbody as the joint’s rest pose. That means that “zero position” and “zero angle” are the pose at the joint’s creation time.

Joint limits are relative to the joint’s rest pose. For example, if some joint limit allows 2 degrees of rotation max, this means 2 degrees with respect to the pose of the joint at the creation time.

When the joint is disabled and re-enabled, the joint is re-created internally. Then the rest pose is reset to whatever position and rotation have at the moment of re-creation. The joint limits are the same (i.e. 2 degrees), but those limits are now with respect to the new pose.

I don’t know any way to configure the joint’s rest pose after it’s created (if there is, please let me know!). The only solution I can think of to disable and re-enable a joint properly is:

  1. Ensure the objects to be joined are in their rest pose, that is, the position and rotation that represent the “zero” for the joined objects.
  2. Enable the joint.

Maybe you could have a script that resets all the poses in your character, then immediately enable the GameObjects.