Ejemplo n.º 1
0
        void Reset()
        {
            bodyMovements = (IVR_BodyMovements)target;
            InstantVR ivr = bodyMovements.GetComponent <InstantVR>();

            if (ivr == null)
            {
                Debug.LogWarning("Body Movements script requires Instant VR script on the game object");
                DestroyImmediate(bodyMovements);
                return;
            }

            IVR_BodyMovements[] bodyMovementsScripts = bodyMovements.GetComponents <IVR_BodyMovements>();
            if (bodyMovementsScripts.Length > 1)
            {
                Debug.LogError("You cant have more than one BodyMovements script");
                DestroyImmediate(bodyMovements); // why does it delete the first script, while target should be the new script...
                return;
            }

            Animator animator = bodyMovements.transform.GetComponentInChildren <Animator>();

            if (animator)
            {
                avatarGameObject = animator.gameObject;

                prefabPose = false;
                bodyMovements.StartMovements();
            }
        }
Ejemplo n.º 2
0
        protected virtual void Awake()
        {
            Screen.sleepTimeout = SleepTimeout.NeverSleep;

            extensions = this.GetComponents <IVR_Extension>();
            foreach (IVR_Extension extension in extensions)
            {
                extension.StartExtension(this);
            }

            headControllers      = headTarget.GetComponents <IVR_Controller>();
            leftHandControllers  = leftHandTarget.GetComponents <IVR_Controller>();
            rightHandControllers = rightHandTarget.GetComponents <IVR_Controller>();
            hipControllers       = hipTarget.GetComponents <IVR_Controller>();
            leftFootControllers  = leftFootTarget.GetComponents <IVR_Controller>();
            rightFootControllers = rightFootTarget.GetComponents <IVR_Controller>();

            headController      = FindActiveController(headControllers);
            leftHandController  = FindActiveController(leftHandControllers);
            rightHandController = FindActiveController(rightHandControllers);
            hipController       = FindActiveController(hipControllers);
            leftFootController  = FindActiveController(leftFootControllers);
            rightFootController = FindActiveController(rightFootControllers);

            headMovements = headTarget.GetComponent <IVR_Movements>();

            leftHandMovements = leftHandTarget.GetComponent <IVR_HandMovementsBase>();
            if (leftHandMovements != null)
            {
                leftHandMovements.selectedController = (IVR_HandController)FindActiveController(leftHandControllers);
            }

            rightHandMovements = rightHandTarget.GetComponent <IVR_HandMovementsBase>();
            if (rightHandMovements != null)
            {
                rightHandMovements.selectedController = (IVR_HandController)FindActiveController(rightHandControllers);
            }


            Animator[] animators = GetComponentsInChildren <Animator>();
            for (int i = 0; i < animators.Length; i++)
            {
                Avatar avatar = animators[i].avatar;
                if (avatar.isValid && avatar.isHuman)
                {
                    characterTransform = animators[i].transform;

                    AddRigidbody(characterTransform.gameObject);
                    bodyCapsule = AddHipCollider(hipTarget.gameObject, proximitySpeed);
                }
            }

            foreach (IVR_Controller c in headControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in leftHandControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in rightHandControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in hipControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in leftFootControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in rightFootControllers)
            {
                c.StartController(this);
            }

            IVR_BodyMovements bm = GetComponent <IVR_BodyMovements>();

            if (bm != null)
            {
                bm.StartMovements();
            }

            if (headMovements && headMovements.enabled)
            {
                headMovements.StartMovements(this);
            }
            if (leftHandMovements != null && leftHandMovements.enabled)
            {
                leftHandMovements.StartMovements(this);
            }
            if (rightHandMovements != null && rightHandMovements.enabled)
            {
                rightHandMovements.StartMovements(this);
            }
        }
Ejemplo n.º 3
0
        protected virtual void Awake()
        {
            Screen.sleepTimeout = SleepTimeout.NeverSleep;

            extensions = this.GetComponents <IVR_Extension>();
            foreach (IVR_Extension extension in extensions)
            {
                extension.StartExtension(this);
            }

            headControllers      = headTarget.GetComponents <IVR_Controller>();
            leftHandControllers  = leftHandTarget.GetComponents <IVR_Controller>();
            rightHandControllers = rightHandTarget.GetComponents <IVR_Controller>();
            hipControllers       = hipTarget.GetComponents <IVR_Controller>();
            leftFootControllers  = leftFootTarget.GetComponents <IVR_Controller>();
            rightFootControllers = rightFootTarget.GetComponents <IVR_Controller>();

            headController      = FindActiveController(headControllers);
            leftHandController  = FindActiveController(leftHandControllers);
            rightHandController = FindActiveController(rightHandControllers);
            hipController       = FindActiveController(hipControllers);
            leftFootController  = FindActiveController(leftFootControllers);
            rightFootController = FindActiveController(rightFootControllers);

            headMovements = headTarget.GetComponent <IVR_Movements>();

            leftHandMovements = leftHandTarget.GetComponent <IVR_HandMovementsBase>();
            if (leftHandMovements != null)
            {
                leftHandMovements.selectedController = (IVR_HandController)FindActiveController(leftHandControllers);
            }

            rightHandMovements = rightHandTarget.GetComponent <IVR_HandMovementsBase>();
            if (rightHandMovements != null)
            {
                rightHandMovements.selectedController = (IVR_HandController)FindActiveController(rightHandControllers);
            }

            DetermineAvatar();

            foreach (IVR_Controller c in headControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in leftHandControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in rightHandControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in hipControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in leftFootControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in rightFootControllers)
            {
                c.StartController(this);
            }

            bodyMovements = GetComponent <IVR_BodyMovements>();
            if (bodyMovements != null)
            {
                bodyMovements.StartMovements();
            }

            if (headMovements && headMovements.enabled)
            {
                headMovements.StartMovements(this);
            }
            if (leftHandMovements != null && leftHandMovements.enabled)
            {
                leftHandMovements.StartMovements(this);
            }
            if (rightHandMovements != null && rightHandMovements.enabled)
            {
                rightHandMovements.StartMovements(this);
            }

            InitGroundcheck();
        }