Example #1
0
        public void MirrorFingersToOtherHand()
        {
            if (!creature)
            {
                creature = this.GetComponentInParent <Creature>();
            }
            foreach (RagdollHand ragdollHand in creature.GetComponentsInChildren <RagdollHand>())
            {
                if (ragdollHand != this)
                {
                    otherHand = ragdollHand;
                    break;
                }
            }
            DestroyImmediate(otherHand.palmCollider.gameObject);
            GameObject otherFingers = Instantiate(palmCollider.gameObject, otherHand.transform);

            otherFingers.name = palmCollider.name;
            otherFingers.transform.MirrorChilds(new Vector3(1, -1, 1));
            // Dirty fix to avoid negative scale
            foreach (Transform transform in otherFingers.GetComponentsInChildren <Transform>())
            {
                transform.localScale = Vector3.one;
            }
            otherHand.SetupFingers();
        }
Example #2
0
 private void OnValidate()
 {
     if (!upperArmBone || !lowerArmBone || !handBone || !armTwistBone)
     {
         RagdollHand ragdollHand = this.GetComponentInParent <RagdollHand>();
         Creature    creature    = this.GetComponentInParent <Creature>();
         if (creature && creature.animator && ragdollHand)
         {
             if (!upperArmBone)
             {
                 upperArmBone = creature.animator.GetBoneTransform(ragdollHand.side == Side.Right ? HumanBodyBones.RightUpperArm : HumanBodyBones.LeftUpperArm);
             }
             if (!lowerArmBone)
             {
                 lowerArmBone = creature.animator.GetBoneTransform(ragdollHand.side == Side.Right ? HumanBodyBones.RightLowerArm : HumanBodyBones.LeftLowerArm);
             }
             if (!armTwistBone)
             {
                 armTwistBone = creature.animator.GetBoneTransform(ragdollHand.side == Side.Right ? HumanBodyBones.RightLowerArm : HumanBodyBones.LeftLowerArm).GetChild(0);
             }
             if (!handBone)
             {
                 handBone = creature.animator.GetBoneTransform(ragdollHand.side == Side.Right ? HumanBodyBones.RightHand : HumanBodyBones.LeftHand);
             }
         }
     }
 }
Example #3
0
 public EditPose(RagdollHand ragdollHand)
 {
     this.ragdollHand = ragdollHand;
 }
Example #4
0
        protected void Awake()
        {
#if PrivateSDK
            this.gameObject.AddComponent <RagdollTester>();
#endif

            foreach (SkinnedMeshRenderer smr in this.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                smr.updateWhenOffscreen = true;
            }
            if (!logGroup)
            {
                logGroup = this.GetComponentInChildren <LODGroup>();
            }
            animator.applyRootMotion = false;
            animator.cullingMode     = AnimatorCullingMode.AlwaysAnimate;
            animator.enabled         = false;
            ragdoll = this.GetComponentInChildren <Ragdoll>();

            brain     = this.GetComponentInChildren <Brain>();
            equipment = this.GetComponentInChildren <Equipment>();
            if (!container)
            {
                container = this.GetComponentInChildren <Container>();
            }

            locomotion = this.GetComponent <Locomotion>();
            mana       = this.GetComponent <Mana>();
            climber    = this.GetComponentInChildren <FeetClimber>();
            speak      = this.GetComponentInChildren <CreatureSpeak>();

            foreach (RagdollHand hand in this.GetComponentsInChildren <RagdollHand>())
            {
                if (hand.side == Side.Right)
                {
                    handRight = hand;
                }
                if (hand.side == Side.Left)
                {
                    handLeft = hand;
                }
            }
            foreach (RagdollFoot foot in this.GetComponentsInChildren <RagdollFoot>())
            {
                if (foot.side == Side.Right)
                {
                    footRight = foot;
                }
                if (foot.side == Side.Left)
                {
                    footLeft = foot;
                }
            }

            if (!hashInitialized)
            {
                InitAnimatorHashs();
            }

#if !PrivateSDK
            Rigidbody locomotionRb = locomotion.GetComponent <Rigidbody>();
            locomotionRb.isKinematic = true;

            foreach (RagdollPart ragdollPart in this.GetComponentsInChildren <RagdollPart>())
            {
                Rigidbody ragdollPartRb = ragdollPart.GetComponent <Rigidbody>();
                ragdollPartRb.isKinematic = true;
                ragdollPart.transform.SetParent(ragdollPart.meshBone);
                ragdollPart.SetPositionToBone();
            }
#endif
        }