Beispiel #1
0
        static void AddComponentesTo(RagdollPartSphere part, RagdollProperties ragdollProperties, float mass, bool addJoint)
        {
            AddComponentesToBase(part, ragdollProperties, mass, addJoint);
            GameObject go = part.transform.gameObject;

            part.collider = GetCollider <SphereCollider>(go.transform);
            if (part.collider == null)
            {
                part.collider = go.AddComponent <SphereCollider>();
            }
            part.collider.isTrigger = ragdollProperties.asTrigger;
        }
Beispiel #2
0
        public Ragdoller(Transform player, Vector3 playerDirection)
        {
            _playerDirection = playerDirection;
            _readyToGenerate = false;

            // find Animator
            Animator animator = FindAnimator(player);

            if (animator == null)
            {
                return;
            }
            _rootNode = animator.transform;

            // specify all parts of ragdoll
            _pelvis     = new RagdollPartBox(animator.GetBoneTransform(HumanBodyBones.Hips));
            _leftHip    = new RagdollPartCapsule(animator.GetBoneTransform(HumanBodyBones.LeftUpperLeg));
            _leftKnee   = new RagdollPartCapsule(animator.GetBoneTransform(HumanBodyBones.LeftLowerLeg));
            _rightHip   = new RagdollPartCapsule(animator.GetBoneTransform(HumanBodyBones.RightUpperLeg));
            _rightKnee  = new RagdollPartCapsule(animator.GetBoneTransform(HumanBodyBones.RightLowerLeg));
            _leftArm    = new RagdollPartCapsule(animator.GetBoneTransform(HumanBodyBones.LeftUpperArm));
            _leftElbow  = new RagdollPartCapsule(animator.GetBoneTransform(HumanBodyBones.LeftLowerArm));
            _rightArm   = new RagdollPartCapsule(animator.GetBoneTransform(HumanBodyBones.RightUpperArm));
            _rightElbow = new RagdollPartCapsule(animator.GetBoneTransform(HumanBodyBones.RightLowerArm));
            _chest      = new RagdollPartBox(animator.GetBoneTransform(HumanBodyBones.Chest));
            _head       = new RagdollPartSphere(animator.GetBoneTransform(HumanBodyBones.Head));

            _leftFoot  = new RagdollPartBox(animator.GetBoneTransform(HumanBodyBones.LeftFoot));
            _rightFoot = new RagdollPartBox(animator.GetBoneTransform(HumanBodyBones.RightFoot));
            _leftHand  = new RagdollPartBox(animator.GetBoneTransform(HumanBodyBones.LeftHand));
            _rightHand = new RagdollPartBox(animator.GetBoneTransform(HumanBodyBones.RightHand));

            if (_chest.transform == null)
            {
                _chest = new RagdollPartBox(animator.GetBoneTransform(HumanBodyBones.Spine));
            }

            if (!CheckFields())
            {
                Debug.LogError("Not all nodes was found!");
                return;
            }

            _readyToGenerate = true;
        }