3

ラグドールを使用して、歩行アニメーションと落下プロセスの間の現実的な移行を試みています。基本的に、「DoRagdoll」関数を呼び出すとき、質量に関してすべてのリジッドボディ コンポーネントに、歩行アニメーションから前の力を追加します。次に、アニメーター コンポーネントを無効にし、すべてのリジッドボディの重力をオンにします。それは機能しますが、それでもちょっと奇妙に見えます。ラグドールの問題については、Unity のドキュメント サイトのようにすでに多くのことを試しました。また、さまざまなボディパーツのジョイントも試しました。ビルトイン システムを使用してラグドールを作成しました。トランジションを改善する方法や、よりリアルなラグドールを作成する方法について何かアイデアはありますか?

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;
    }
}
4

0 に答える 0