Exemplo n.º 1
0
        void Start()
        {
            characterController = GetComponentInChildren <CharacterController>();

            pControl = GetComponentInChildren <OVRPlayerController>();
            _initialGravityModifier = pControl.GravityModifier;

            _initialPosition = characterController.transform.position;
            float initialY = _initialPosition.y;

            if (initialY < MinElevation)
            {
                Debug.LogWarning("Initial Starting Position is lower than Minimum Elevation. Increasing Min Elevation to " + MinElevation);
                MinElevation = initialY;
            }
            if (initialY > MaxElevation)
            {
                Debug.LogWarning("Initial Starting Position is greater than Maximum Elevation. Reducing Max Elevation to " + MaxElevation);
                MaxElevation = initialY;
            }

            teleport = GetComponent <PlayerTeleport>();

            climbers = new List <Grabber>();

            ChangeLocomotionType(selectedLocomotion);
        }
Exemplo n.º 2
0
 void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <CharacterController>())
     {
         PlayerTeleport pt = other.transform.parent.GetComponent <PlayerTeleport>();
         if (pt && TeleportDestination)
         {
             pt.TeleportPlayerToTransform(TeleportDestination);
         }
     }
 }
        public void ChangeLocomotionType(LocomotionType loc)
        {
            selectedLocomotion = loc;

            if (teleport == null)
            {
                teleport = GetComponent <PlayerTeleport>();
            }

            toggleTeleport(selectedLocomotion == LocomotionType.Teleport);
            toggleSmoothLocomotion(selectedLocomotion == LocomotionType.SmoothLocomotion);
        }
        void Start()
        {
            characterController = GetComponentInChildren <CharacterController>();
            mainCamera          = Camera.main.transform;

            if (characterController)
            {
                _initialCharacterParent = characterController.transform.parent;
            }

            _initialGravityModifier = GravityAmount;

            _initialPosition = characterController.transform.position;
            float initialY = _initialPosition.y;

            if (initialY < MinElevation)
            {
                Debug.LogWarning("Initial Starting Position is lower than Minimum Elevation. Increasing Min Elevation to " + MinElevation);
                MinElevation = initialY;
            }
            if (initialY > MaxElevation)
            {
                Debug.LogWarning("Initial Starting Position is greater than Maximum Elevation. Reducing Max Elevation to " + MaxElevation);
                MaxElevation = initialY;
            }

            teleport         = GetComponent <PlayerTeleport>();
            smoothLocomotion = GetComponentInChildren <SmoothLocomotion>();
            playerRotation   = GetComponentInChildren <PlayerRotation>();

            climbers = new List <Grabber>();

            // Player root must be at 0,0,0 for Tracking Space to work properly.
            // If this player transform was moved in the editor on load, we can fix it by moving the CharacterController to the position
            if (transform.position != Vector3.zero || transform.localEulerAngles != Vector3.zero)
            {
                Vector3    playerPos = transform.position;
                Quaternion playerRot = transform.rotation;

                transform.position = Vector3.zero;
                transform.rotation = Quaternion.identity;

                if (characterController)
                {
                    characterController.transform.position = playerPos;
                    characterController.transform.rotation = playerRot;
                }

                Debug.Log("Player position not set to 0. Moving player to : " + playerPos);
            }

            ChangeLocomotionType(selectedLocomotion);
        }
Exemplo n.º 5
0
        void Start()
        {
            if (GameObject.Find("CameraRig"))
            {
                mainCameraTransform = GameObject.Find("CameraRig").transform;
            }
            // Oculus Rig Setup
            else if (GameObject.Find("OVRCameraRig"))
            {
                mainCameraTransform = GameObject.Find("OVRCameraRig").transform;
            }

            leftHandAnchor  = GameObject.Find("LeftHandAnchor").transform;
            rightHandAnchor = GameObject.Find("RightHandAnchor").transform;

            leftControllerTranform  = GameObject.Find("LeftControllerAnchor").transform;
            rightControllerTranform = GameObject.Find("RightControllerAnchor").transform;

            player = FindObjectOfType <BNGPlayerController>();

            if (player)
            {
                // Use this to keep our head up high
                player.ElevateCameraIfNoHMDPresent = true;
                _originalPlayerYOffset             = player.ElevateCameraHeight;

                smoothLocomotion = player.GetComponentInChildren <SmoothLocomotion>(true);

                // initialize component if it's currently disabled
                if (smoothLocomotion != null && !smoothLocomotion.isActiveAndEnabled)
                {
                    smoothLocomotion.CheckControllerReferences();
                }

                playerTeleport = player.GetComponentInChildren <PlayerTeleport>(true);
                if (playerTeleport)
                {
                    priorStraightSetting = playerTeleport.ForceStraightArrow;
                }

                if (smoothLocomotion == null)
                {
                    Debug.Log("No Smooth Locomotion component found. Will not be able to use SmoothLocomotion without calling it manually.");
                }
                else if (smoothLocomotion.MoveAction == null)
                {
                    Debug.Log("Smooth Locomotion Move Action has not been assigned. Make sure to assign this in the inspector if you want to be able to move around using the VR Emulator.");
                }
            }
        }
Exemplo n.º 6
0
        void Start()
        {
            player   = GetComponent <BNGPlayerController>();
            teleport = GetComponent <PlayerTeleport>();

            // Load Locomotion Preference
            if (LoadLocomotionFromPrefs)
            {
                ChangeLocomotion(PlayerPrefs.GetInt("LocomotionSelection", 0) == 0 ? LocomotionType.Teleport : LocomotionType.SmoothLocomotion, false);
            }
            else
            {
                ChangeLocomotion(DefaultLocomotion, false);
            }
        }
Exemplo n.º 7
0
        public void ChangeLocomotionType(LocomotionType loc)
        {
            // Make sure Smooth Locomotion is available
            if (smoothLocomotion == null)
            {
                smoothLocomotion = GetComponent <SmoothLocomotion>();
            }

            selectedLocomotion = loc;

            if (teleport == null)
            {
                teleport = GetComponent <PlayerTeleport>();
            }

            toggleTeleport(selectedLocomotion == LocomotionType.Teleport);
            toggleSmoothLocomotion(selectedLocomotion == LocomotionType.SmoothLocomotion);
        }
Exemplo n.º 8
0
        public void ChangeLocomotionType(LocomotionType loc)
        {
            selectedLocomotion = loc;

            if (teleport == null)
            {
                teleport = GetComponent <PlayerTeleport>();
            }

            if (selectedLocomotion == LocomotionType.Teleport)
            {
                teleport.EnableTeleportation();
            }
            else if (selectedLocomotion == LocomotionType.SmoothLocomotion)
            {
                teleport.DisableTeleportation();
            }
            // Default to Disable All
            else
            {
                // Disable all
                teleport.DisableTeleportation();
            }
        }