예제 #1
0
    public void switchToRagdoll()
    {
        if (!isRagdollMode)
        {
            act.tfObservedCenter = tfRagdollHeadCenter;

            var tfWapon = act.playerShoot.weapons.current.tf;

            tfWapon.parent = tfRagdollHand;

            tfWapon.localPosition = Vector3.zero;

            tfWapon.localRotation = Quaternion.identity;



            //tfRagdollBase.gameObject.SetActive( true );// ここじゃだめ

            for (var i = 1; i < tfBodyParts.Length; i++)
            {
                var tfBodyPart = tfBodyParts[i];

                var tfRagdollPart = tfRagdollParts[i];

                var rbRagdollPart = rbRagdollParts[i];

                /*
                 * if( rbRagdollPart != null )
                 * {
                 *      //rbRagdollPart.position = tfBodyPart.position;
                 *
                 *      //rbRagdollPart.rotation = tfBodyPart.rotation;
                 *
                 *      rbRagdollPart.velocity = act.rb.velocity;//Vector3.zero;//
                 *
                 *      rbRagdollPart.angularVelocity = act.rb.angularVelocity;//Vector3.zero;//
                 * }
                 * else*/
                if (tfRagdollPart != null)
                {
                    tfRagdollPart.localPosition = tfBodyPart.localPosition;

                    tfRagdollPart.localRotation = tfBodyPart.localRotation;
                }
                else
                {
                    Debug.Log(tfBodyPart.name);
                }
            }

            tfRagdollBase.position = tfBodyBase.position;

            tfRagdollBase.rotation = tfBodyBase.rotation;

            rbRagdollParts[0].velocity = act.rb.velocity;

            rbRagdollParts[0].angularVelocity = act.rb.angularVelocity;


            act.activateCollider(false);

            act.rb.isKinematic = true;


            tfBodyBase.gameObject.SetActive(false);

            tfRagdollBase.gameObject.SetActive(true);              // ここじゃないとだめっぽい

            smr.switchBones(tfRagdollParts);


            //switchObservedCenter();
        }
    }