There is a way to make a Hybrid Unit/Ragdoll that won’t interfere with those annoying bullet physics:
- Find each RigidBody on the character that is a Ragdoll joint and change the GameObject’s Tag to “Ragdoll”
- Add this Ragdoll Minder script:
public class Ragdoll
private Collider[] allColliders;
private Rigidbody[] allRigidbodies;
private void Start()
{
allColliders = GetComponentsInChildren<Collider>(true);
allRigidbodies = GetComponentsInChildren<Rigidbody>(true);
ToggleRagdoll(false);
}
public void ToggleRagdoll(bool isRagdoll)
{
foreach (Collider collider in allColliders)
{
if (collider.gameObject.CompareTag("Ragdoll"))
{
collider.enabled = isRagdoll;
}
}
foreach (Rigidbody rigidbody in allRigidbodies)
{
if (rigidbody.gameObject.CompareTag("Ragdoll"))
{
rigidbody.isKinematic = !isRagdoll;
rigidbody.useGravity = isRagdoll;
}
}
}
When you want to set the character to Ragdoll (when it dies), call
GetComponent<Ragdoll>().ToggleRagdoll(true);