public override void OnHeldMouse(float mouseMoveX, float mouseMoveY) { if (mouseMoveX == 0.0f && mouseMoveY == 0.0f) { return; } // The physical camera object in the level is the one with the RotLimit script if (camScript.gameObjectParentedTo != null) { CameraRotationLimit camRotLimit = GetScript <CameraRotationLimit>(camScript.gameObjectParentedTo, false); if (camRotLimit != null) { camRotLimit.xCurrentRotation += mouseMoveX * 5.0f; // script has clamped this rotation, in degrees camRotLimit.yCurrentRotation += mouseMoveY * 5.0f; camScript.SetUpdateLookAtDirAndPosition(); } } }
public void UpdateXboxInputs() { float dt = FrameController.DT(); Vector3 centerPos = ocuCam.transform.position + (Vector3)ocuCam.transform.GetForwardVector() * mMousePositionFromOcuCam.Z; gameObject.transform.SetPosition(centerPos); // Always at the center of oculus screen // Update dpad Xbox controls for selecting camInMap icons bool upTriggered = Input.GetTriggered((char)0, "ArrowUp") != 0; bool leftTriggered = Input.GetTriggered((char)0, "ArrowLeft") != 0; bool downTriggered = Input.GetTriggered((char)0, "ArrowDown") != 0; bool rightTriggered = Input.GetTriggered((char)0, "ArrowRight") != 0; if (upTriggered || leftTriggered || downTriggered || rightTriggered) { if (upTriggered || leftTriggered) // decrements { if (camInMapIndex > 0) { --camInMapIndex; // [0, length - 1] } } else // downTriggered || rightTriggered // increments { if (camInMapIndex + 1 < camInMap.Count) { ++camInMapIndex; // [0, length - 1] } } // Vector3 camInMapPos = (Vector3)camInMap[camInMapIndex].transform.position; // camInMapSelector.gameObject.transform.SetPositionX(camInMapPos.X); // camInMapSelector.gameObject.transform.SetPositionY(camInMapPos.Y); } // 'X' to select active camera if (Input.GetTriggered(0, "Xbox_X") != 0) { pickedObject = camInMap[camInMapIndex]; CameraInMap camMapScript = GetScript <CameraInMap>(pickedObject); // Only change camera if picked cam icon is disabled (not nonActive or already picked) if (camMapScript.isActive && !camMapScript.isEnabled) { // Set previous camInMap back to disable for feedback if (prevPickedObject != null) { CameraInMap prevCamMapScript = GetScript <CameraInMap>(prevPickedObject); if (prevCamMapScript.isEnabled && prevCamMapScript.isActive) { prevCamMapScript.isEnabled = false; } } // Set that camInMap to green for feedback prevPickedObject = pickedObject; camMapScript.isEnabled = true; } // End of if picked a disabled camera (then enable it) } // Updating the camera screen rotation based on Right Thumbstick of Xbox if (camScript.gameObjectParentedTo != null && camScript.gameObjectParentedTo != Common.GetNoiseStatic()) { float xboxX = Input.GetValue((char)0, "RThumbX"); float xboxY = Input.GetValue((char)0, "RThumbY"); if (xboxX != 0.0f || xboxY != 0.0f) { // The physical camera object in the level is the one with the RotLimit script CameraRotationLimit camRotLimit = GetScript <CameraRotationLimit>(camScript.gameObjectParentedTo); camRotLimit.xCurrentRotation += xboxX * 1.3f * dt; // script has clamped this rotation, in degrees camRotLimit.yCurrentRotation += xboxY * 1.3f * dt; camScript.SetUpdateLookAtDirAndPosition(); } } }