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."); } } }
public void CheckPlayerControls() { // Require focus if (RequireGameFocus && Application.isEditor && !Application.isFocused) { return; } // Player Up / Down if (AllowUpDownControls) { if (PlayerUpAction != null && PlayerUpAction.action.ReadValue <float>() == 1) { player.ElevateCameraHeight = Mathf.Clamp(player.ElevateCameraHeight + Time.deltaTime, 0.2f, 5f); } else if (PlayerDownAction != null && PlayerDownAction.action.ReadValue <float>() == 1) { player.ElevateCameraHeight = Mathf.Clamp(player.ElevateCameraHeight - Time.deltaTime, 0.2f, 5f); } } // Force Forward Arrow if (ForceStraightTeleportRotation && playerTeleport != null && playerTeleport.ForceStraightArrow == false) { playerTeleport.ForceStraightArrow = true; } // Player Move Forward / Back, Snap Turn if (smoothLocomotion != null && smoothLocomotion.enabled == false) { // Manually allow player movement if the smooth locomotion component is disabled smoothLocomotion.CheckControllerReferences(); smoothLocomotion.UpdateInputs(); if (smoothLocomotion.ControllerType == PlayerControllerType.CharacterController) { smoothLocomotion.MoveCharacter(); } else if (smoothLocomotion.ControllerType == PlayerControllerType.Rigidbody) { smoothLocomotion.MoveRigidCharacter(); } } }
public void CheckPlayerControls() { // Player Up / Down if (Input.GetKey(PlayerUp)) { player.ElevateCameraHeight = Mathf.Clamp(player.ElevateCameraHeight + Time.deltaTime, 0.2f, 5f); } else if (Input.GetKey(PlayerDown)) { player.ElevateCameraHeight = Mathf.Clamp(player.ElevateCameraHeight - Time.deltaTime, 0.2f, 5f); } // Player Move Forward / Back, Snap Turn if (smoothLocomotion != null && smoothLocomotion.enabled == false) { // Manually allow player movement if the smooth locomotion component is disabled smoothLocomotion.CheckControllerReferences(); smoothLocomotion.UpdateInputs(); smoothLocomotion.MoveCharacter(); } }