public void DismemberBone(Ragdoll ragdoll, RagdollTransform bone, int delay, bool isFollowBone = false) { InitializeDismemberedBones(); if (!isFollowBone) { if (!dismemberableBones.Contains(bone.bone.bone)) { return; } if (delay > 0) { ragdoll.StartCoroutine(DismemberBoneDelayed(ragdoll, bone, delay)); return; } dismemberedBones[bone.bone.bone] = bone; bone.collider.gameObject.layer = LayerMask.NameToLayer(ignorePhysicsLayer); // bone.joint.connectedBody = null; // bone.collider.isTrigger = true; // bone.SetKinematic(true); // dismember the follow target, so it reflects our dismemberment // (dismembers the animated model...) if (bone.followTarget != null) { DismemberBone(ragdoll, bone.followTarget, 0, true); } // dismember and disable any child bones (helps physics from getting all jittery) HumanBodyBones childBone = Ragdoll.GetChildBone(bone.bone.bone); if (childBone != HumanBodyBones.Hips) { RagdollTransform childBoneTransform = ragdoll.GetBone(childBone); if (!BoneDismembered(childBoneTransform)) { DismemberBone(ragdoll, childBoneTransform, 0, false); } } } bone.transform.localScale = Vector3.one * dismemberScale; }
public void DismemberBone(string reason, Ragdoll ragdoll, RagdollTransform bone) { InitializeDismemberedBones(); if (!dismembermentAvailable) { return; } if (!BoneDismemberable(bone.bone.bone)) { return; } if (RagdollPhysics.RigidbodyGrabbed(bone.rigidbody)) { return; } // Debug.LogError("Dismembered " + reason); dismemberedBones[bone.bone.bone] = bone; // dismember the follow target, so it reflects our dismemberment // (dismembers the animated model...) if (bone.followTarget != null) { DismemberBone(ragdoll, bone.followTarget, true); } // dismember and disable any child bones (helps physics from getting all jittery) HumanBodyBones childBone = Ragdoll.GetChildBone(bone.bone.bone); RagdollTransform childBoneTransform = ragdoll.GetBone(childBone); if (!BoneDismembered(childBoneTransform)) { DismemberBone(reason, ragdoll, childBoneTransform); } ragdoll.StartCoroutine(DismemberBoneDelayed(ragdoll, bone)); }