3

I'm trying to make a realistic transition between a walking animation and the falling process with a ragdoll. Basically when calling the "DoRagdoll" function, I'm adding the previous force from the walking animation to all rigidbody components in respect of their masses. Then I deactivate the animator component and turn on gravity for all rigidbodies. It works but it still kinda looks weird. I already tried a lot like the Unity documentation site for problems with ragdolls and I also played around with the joints of the different bodyparts. I used the buildin system to create the ragdoll. Any Ideas on how to improve the transition or how to create a more realistic ragdoll?

void Awake()
{
    rbs = GetComponentsInChildren<Rigidbody>();
    DoRagdoll(false);
    foreach (Rigidbody rb in rbs)
    {
        rb.useGravity = false;
        //rb.isKinematic = true;
    }
}

public void DoRagdoll (bool isRagdoll)
{
    if (isRagdoll)
    {
        foreach (Rigidbody rb in rbs)
        {
            rb.AddForce(rb.mass * rb.velocity, ForceMode.Impulse);
        }
    }
    GetComponent<Animator>().enabled = !isRagdoll;
    if (isRagdoll)
    {
        foreach (Rigidbody rb in rbs)
        {
            rb.maxDepenetrationVelocity = 0.01f;
            rb.useGravity = true;
            //rb.isKinematic = false;
        }
        NavMeshAgent agent = GetComponent<NavMeshAgent>();
        //GameObject.FindGameObjectWithTag("pelvis").GetComponent<PelvisPush>().PushPelvis();
        rbSlowdown = true;
        ragdollOn = true;
    }
    else
    {
        GetComponent<NavMeshAgent>().speed = GameObject.FindGameObjectWithTag("root").GetComponent<OldmanMovement>().movSpeed;
        foreach (Rigidbody rb in rbs)
        {
            rb.useGravity = false;
            //rb.isKinematic = true;
        }
        ragdollOn = false;
    }
}
SoulPixel
  • 31
  • 6
  • Did you try the builtin ragdoll ? It's not the best thing ever, but works pretty well. Exemple : https://www.youtube.com/watch?v=kux48zqUQY8 – Jichael Oct 16 '19 at 09:32
  • Yes, I used the builtin system to create the ragdoll. But it looks better in the video. Maybe I need to adjust the joints and colliders a bit more. – SoulPixel Oct 16 '19 at 09:40

0 Answers0