Hello,
I have a ragdoll character in unity that is made of ConfigurableJoints, for which I created a movement scripts that enables and disables the ragdoll without setting the rigidbodies to kinematic.
For the enable method, I set each rigidbody’s spring and damper with different values, and so with the disable method.
When I added the ability to rotate the camera with Cinemachine, the character would jitter intensly and not stop.
This also occurs if selected in the hierarchy.
Why does this happen?
Here is the code for further clarification:
public void EnableRagdoll() {
isRagdoll = true;
rb.mass = ragdollRbMass;
for (int i = 0; i < sealColliders.Count; i++)
{
ConfigurableJoint joint = sealColliders[i].GetComponent<ConfigurableJoint>();
JointDrive _angularXDrive = joint.angularXDrive;
JointDrive _angularYZDrive = joint.angularYZDrive;
_angularXDrive.positionSpring = postionRagdollSprings[i];
_angularXDrive.positionDamper = postionRagdollDampers[i];
_angularYZDrive.positionSpring = postionRagdollSprings[i];
_angularYZDrive.positionDamper = postionRagdollDampers[i];
joint.angularXDrive = _angularXDrive;
joint.angularYZDrive = _angularYZDrive;
}
}
public void DisableRagdoll() {
isRagdoll = false;
rb.mass = rbMass;
for (int i = 0; i < sealColliders.Count; i++)
{
ConfigurableJoint joint = sealColliders[i].GetComponent<ConfigurableJoint>();
JointDrive _angularXDrive = joint.angularXDrive;
JointDrive _angularYZDrive = joint.angularYZDrive;
_angularXDrive.positionSpring = postionSprings[i];
_angularXDrive.positionDamper = postionDampers[i];
_angularYZDrive.positionSpring = postionSprings[i];
_angularYZDrive.positionDamper = postionDampers[i];
joint.angularXDrive = _angularXDrive;
joint.angularYZDrive = _angularYZDrive;
}
}