//[HideInInspector]
        //private IVR_HandMovements handMovements;

        public override void StartController(InstantVR ivr)
        {
            extension = ivr.GetComponent <IVR_Animator>();
            base.StartController(ivr);

            animatorHip     = ivr.hipTarget.GetComponent <IVR_AnimatorHip>();
            lastHipPosition = ivr.hipTarget.position;

            //handMovements = GetComponent<IVR_HandMovements>();

            hip2hand = Quaternion.Inverse(ivr.transform.rotation) * (ivr.hipTarget.position - this.transform.position);
            if (this.transform == ivr.leftHandTarget)
            {
                foot2hand      = Quaternion.Inverse(ivr.transform.rotation) * (ivr.leftHandTarget.position - ivr.rightFootTarget.position);
                footController = ivr.rightFootTarget.GetComponent <IVR_Controller>();
            }
            else
            {
                foot2hand      = Quaternion.Inverse(ivr.transform.rotation) * (ivr.rightHandTarget.position - ivr.leftFootTarget.position);
                footController = ivr.leftFootTarget.GetComponent <IVR_Controller>();
            }

            if (footController.GetType() == typeof(IVR_AnimatorFoot) && !footController.enabled)
            {
                footController = null;
            }
        }
示例#2
0
        public override void StartController(InstantVR ivr)
        {
            base.StartController(ivr);

            animatorHip              = ivr.hipTarget.GetComponent <IVR_AnimatorHip>();
            lastHipPosition          = ivr.hipTarget.position;
            animatorHipStartPosition = ivr.hipTarget.position;

            hip2hand = Quaternion.Inverse(ivr.transform.rotation) * (ivr.hipTarget.position - this.transform.position);
            if (this.transform == ivr.leftHandTarget)
            {
                foot2hand = Quaternion.Inverse(ivr.transform.rotation) * (ivr.leftHandTarget.position - ivr.rightFootTarget.position);
            }
            else
            {
                foot2hand = Quaternion.Inverse(ivr.transform.rotation) * (ivr.rightHandTarget.position - ivr.leftFootTarget.position);
            }
        }
示例#3
0
        void OnDestroy()
        {
            InstantVR ivr = this.GetComponent <InstantVR>();

            if (ivr != null)
            {
                IVR_AnimatorHead defaultHead = ivr.headTarget.GetComponent <IVR_AnimatorHead>();
                if (defaultHead != null)
                {
                    DestroyImmediate(defaultHead);
                }

                IVR_AnimatorHand defaultLeftHand = ivr.leftHandTarget.GetComponent <IVR_AnimatorHand>();
                if (defaultLeftHand != null)
                {
                    DestroyImmediate(defaultLeftHand);
                }

                IVR_AnimatorHand defaultRightHand = ivr.rightHandTarget.GetComponent <IVR_AnimatorHand>();
                if (defaultRightHand != null)
                {
                    DestroyImmediate(defaultRightHand);
                }

                IVR_AnimatorHip defaultHip = ivr.hipTarget.GetComponent <IVR_AnimatorHip>();
                if (defaultHip != null)
                {
                    DestroyImmediate(defaultHip);
                }

                IVR_AnimatorFoot defaultLeftFoot = ivr.leftFootTarget.GetComponent <IVR_AnimatorFoot>();
                if (defaultLeftFoot != null)
                {
                    DestroyImmediate(defaultLeftFoot);
                }

                IVR_AnimatorFoot defaultRightFoot = ivr.rightFootTarget.GetComponent <IVR_AnimatorFoot>();
                if (defaultRightFoot != null)
                {
                    DestroyImmediate(defaultRightFoot);
                }
            }
        }
示例#4
0
        void OnDestroy()
        {
            if (ivranimator == null && ivr != null)
            {
                animatorHead = ivr.headTarget.GetComponent <IVR_AnimatorHead>();
                if (animatorHead != null)
                {
                    DestroyImmediate(animatorHead, true);
                }

                animatorLeftHand = ivr.leftHandTarget.GetComponent <IVR_AnimatorHand>();
                if (animatorLeftHand != null)
                {
                    DestroyImmediate(animatorLeftHand, true);
                }

                animatorRightHand = ivr.rightHandTarget.GetComponent <IVR_AnimatorHand>();
                if (animatorRightHand != null)
                {
                    DestroyImmediate(animatorRightHand, true);
                }

                animatorHip = ivr.hipTarget.GetComponent <IVR_AnimatorHip>();
                if (animatorHip != null)
                {
                    DestroyImmediate(animatorHip, true);
                }

                animatorLeftFoot = ivr.leftFootTarget.GetComponent <IVR_AnimatorFoot>();
                if (animatorLeftFoot != null)
                {
                    DestroyImmediate(animatorLeftFoot, true);
                }

                animatorRightFoot = ivr.rightFootTarget.GetComponent <IVR_AnimatorFoot>();
                if (animatorRightFoot != null)
                {
                    DestroyImmediate(animatorRightFoot, true);
                }
            }
        }
示例#5
0
        void OnEnable()
        {
            ivranimator = (IVR_Animator)target;
            if (!ivranimator)
            {
                return;
            }

            ivr = ivranimator.GetComponent <InstantVR>();

            if (ivr != null)
            {
                animatorHead = ivr.headTarget.GetComponent <IVR_AnimatorHead>();
                if (animatorHead == null)
                {
                    animatorHead           = ivr.headTarget.gameObject.AddComponent <IVR_AnimatorHead>();
                    animatorHead.extension = ivranimator;
                }

                animatorLeftHand = ivr.leftHandTarget.GetComponent <IVR_AnimatorHand>();
                if (animatorLeftHand == null)
                {
                    animatorLeftHand           = ivr.leftHandTarget.gameObject.AddComponent <IVR_AnimatorHand>();
                    animatorLeftHand.extension = ivranimator;
                }

                animatorRightHand = ivr.rightHandTarget.GetComponent <IVR_AnimatorHand>();
                if (animatorRightHand == null)
                {
                    animatorRightHand           = ivr.rightHandTarget.gameObject.AddComponent <IVR_AnimatorHand>();
                    animatorRightHand.extension = ivranimator;
                }

                animatorHip = ivr.hipTarget.GetComponent <IVR_AnimatorHip>();
                if (animatorHip == null)
                {
                    animatorHip           = ivr.hipTarget.gameObject.AddComponent <IVR_AnimatorHip>();
                    animatorHip.extension = ivranimator;
                }

                animatorLeftFoot = ivr.leftFootTarget.GetComponent <IVR_AnimatorFoot>();
                if (animatorLeftFoot == null)
                {
                    animatorLeftFoot           = ivr.leftFootTarget.gameObject.AddComponent <IVR_AnimatorFoot>();
                    animatorLeftFoot.extension = ivranimator;
                }

                animatorRightFoot = ivr.rightFootTarget.GetComponent <IVR_AnimatorFoot>();
                if (animatorRightFoot == null)
                {
                    animatorRightFoot           = ivr.rightFootTarget.gameObject.AddComponent <IVR_AnimatorFoot>();
                    animatorRightFoot.extension = ivranimator;
                }

                IVR_Extension[] extensions = ivr.GetComponents <IVR_Extension>();
                if (ivranimator.priority == -1)
                {
                    ivranimator.priority = extensions.Length - 1;
                }
                for (int i = 0; i < extensions.Length; i++)
                {
                    if (ivranimator == extensions[i])
                    {
                        while (i < ivranimator.priority)
                        {
                            MoveUp(animatorHead);
                            MoveUp(animatorLeftHand);
                            MoveUp(animatorRightHand);
                            MoveUp(animatorHip);
                            MoveUp(animatorLeftFoot);
                            MoveUp(animatorRightFoot);
                            ivranimator.priority--;
                            //Debug.Log ("Animator Move up to : " + i + " now: " + ivranimator.priority);
                        }
                        while (i > ivranimator.priority)
                        {
                            MoveDown(animatorHead);
                            MoveDown(animatorLeftHand);
                            MoveDown(animatorRightHand);
                            MoveDown(animatorHip);
                            MoveDown(animatorLeftFoot);
                            MoveDown(animatorRightFoot);
                            ivranimator.priority++;
                            //Debug.Log ("Animator Move down to : " + i + " now: " + ivranimator.priority);
                        }
                    }
                }
            }
        }