- Home /
Ragdoll stucks in objects
Hello guys, I am trying to make death system with ragdoll physics. When i start game with activated ragdoll - everything works correct, but when i activate it after project starts - my ragdoll stucks in floor. I have two arrays: one with ragdoll colliders, another one with rigidbodies. I use boollean variable isAliive, to controll my ragdoll state.
public class RagdollController : MonoBehaviour
{
public CapsuleCollider capsule;
public Rigidbody rb;
public Rigidbody[] rigidbodies;
public Collider[] colliders;
public bool isAlive = true;
public Animator anim;
void Start()
{
rb = GetComponent < Rigidbody >();
capsule = GetComponent<CapsuleCollider>();
anim = GetComponent<Animator>();
rigidbodies = GetComponent<Rigidbody[]>();
colliders = GetComponent<Collider[]>();
}
private void Update()
{
if (isAlive == true)
{
SetRigidBodyState(rigidbodies, false);
SetColliderState(colliders, false);
}
else
{
rb.useGravity = false;
rb.isKinematic = false;
capsule.enabled = false;
anim.enabled = false;
SetRigidBodyState(rigidbodies, true);
SetColliderState(colliders, true);
}
}
void SetRigidBodyState(Rigidbody[] rigidbodies, bool state)
{
if (state == false)
{
foreach (Rigidbody rb in rigidbodies)
{
rb.constraints = RigidbodyConstraints.FreezeRotation;
}
}
else if(state == true)
{
foreach (Rigidbody rb in rigidbodies)
{
rb.constraints = RigidbodyConstraints.None;
}
}
}
void SetColliderState(Collider[] colliders, bool state)
{
foreach (Collider col in colliders)
{
col.enabled = state;
}
}
}
I tried to incrase my capsule collider, tried to chage size of ragdoll colliders, use different constraints from rigidbody, but they didn't help - my character continued his stucking again and again
Your answer
Follow this Question
Related Questions
Ragdoll with multiple colliders 0 Answers
How to fix Colliders flying off after activation? 1 Answer
Ragdoll help 0 Answers
rigidbody simulation collision check frequency check control?? 0 Answers
Adding components to 3d models 1 Answer