Search Unity

Question Removing rig layer from rig builder

Discussion in 'Animation Rigging' started by zenwatermelon168, Oct 17, 2021.

  1. zenwatermelon168

    zenwatermelon168

    Joined:
    Sep 23, 2020
    Posts:
    6
    I have a setup where a character has multiple rigs. I want to do a partial ragdoll by removing a rig layer from the rigbuilder. this is the code i have now:

    Code (CSharp):
    1.     public void RagdollOnForBodyPart(BodyPartType type) {
    2.         foreach (BodyPart part in _bodyParts) {
    3.             if (part.type == type) {
    4.                 part.TurnOnRagdoll();  //enables ragdoll physics on limb
    5.               //remove layer associated with limb
    6.                 if(part.GetRig() != null ) {
    7.                     for(int i =0;i< rigBuilder.layers.Count; i++) {
    8.                         if (rigBuilder.layers[i].rig == part.GetRig()) {
    9.                             rigBuilder.layers.RemoveAt(i);
    10.                             rigBuilder.Build();
    11.                             break;
    12.                         }
    13.                     }
    14.                
    15.                 }
    16.                 break;
    17.             }
    18.         }
    19.         }
    However, even though the rig layer gets removed, the limb gets frozen in place. Checking colliders/rigidbodies, all have physics and colliders enabled. What's interesting is that if all the layers were removed, and you called rigbuilder.build(), it would work. Or if you removed all rig layers and then added the ones you needed back in manually one by one, it would work. What is the issue here?