private void Update() { if (_rightHandIndex == -1) { _rightHandIndex = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Rightmost); } if (_leftHandIndex == -1) { _leftHandIndex = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost); } if (Input.GetKeyDown(KeyCode.Space) || (_leftHandIndex != -1 && LeftController.GetHairTriggerDown())) { _spacebarDown = true; if (!_experimentCommenced) { _experimentCommenced = true; StartCoroutine(RunExperiment()); } } else { _spacebarDown = false; } if (_recordingData) { RecordPosesDataToBuffer(); } if (Input.GetKeyDown(KeyCode.G)) { UI.CalibrationLines.SetActive(!UI.CalibrationLines.activeInHierarchy); } if (Input.GetKeyDown(KeyCode.Backspace)) { StartCoroutine(EmergencyFlushBufferAndQuit()); } // If tracking the pole positions, update the virtual pole position and experimenter display every frame. if (!_poleTrackersAssigned) { return; } var rightPolePosition = _trackedDevices[_trackedDeviceRoles[DeviceRole.PoleRight]].transform.position; var leftPolePosition = _trackedDevices[_trackedDeviceRoles[DeviceRole.PoleLeft]].transform.position; _poleRight.transform.position = new Vector3(rightPolePosition.x, _poleHeightRight / 2f, rightPolePosition.z); _poleLeft.transform.position = new Vector3(leftPolePosition.x, _poleHeightRight / 2f, leftPolePosition.z); var apertureText = new StringBuilder(); apertureText.AppendFormat((Vector3.Distance(_poleLeft.transform.position, _poleRight.transform.position) - Parameters.VirtualPoleDiameter).ToString("F4")); apertureText.AppendFormat(" LeftX: {0:F4} RightX: {1:F4}", _poleLeft.transform.position.x, _poleRight.transform.position.x); UI.ApertureValue.text = apertureText.ToString(); }
// Update is called once per frame void Update() { // シーンコントローラが所得できてるかをチェック if (sceneController) { // ここでシーンの切り替える条件などを書いてください if (Input.GetKeyDown(KeyCode.Return)) { // sceneController.SceneChange( シーンの列挙子 )を呼び出すとシーンを変えることができます sceneController.SceneChange(SceneController.SceneState.GameMain); } if (LeftController) { // 左コントローラの操作 if (LeftController.GetGripDown()) { sceneController.SceneChange(SceneController.SceneState.GameMain); } if (LeftController.GetHairTriggerDown()) { sceneController.SceneChange(SceneController.SceneState.GameMain); } } if (RightController) { // 右コントローラの操作 if (RightController.GetGripDown()) { sceneController.SceneChange(SceneController.SceneState.GameMain); } if (RightController.GetHairTriggerDown()) { sceneController.SceneChange(SceneController.SceneState.GameMain); } } } else { // ここではシーンコントローラが所得できなかった場合の処理を書きます sceneController = GameObject.Find("[SceneManager]").GetComponent <SceneController>(); } }
private void Update() { //Drawing laser and picking up object RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, 100)) { _hitPoint = hit.point; ShowLaser(hit); if ((LeftController.GetHairTriggerDown() || RightController.GetHairTriggerDown()) && !heldGameObject && hit.collider.gameObject.GetComponent <Rigidbody>()) { if (applicationController.currentCube == hit.collider.gameObject) { applicationController.LogCorrectObject(-1.0f); } else { applicationController.LogWrongObject(-1.0f); } GrabObject(hit.collider.gameObject); } else if ((LeftController.GetHairTriggerDown() || RightController.GetHairTriggerDown()) && !heldGameObject) { applicationController.LogMissedObject(-1.0f); } } //Releasing an object if ((LeftController.GetHairTriggerUp() || RightController.GetHairTriggerUp()) && heldGameObject) { applicationController.LogDroppedObject(); ReleaseObject(); } else if (heldGameObject && !GetComponent <FixedJoint>()) { FixedJoint joint = AddFixedJoint(); joint.connectedBody = heldGameObject.GetComponent <Rigidbody>(); } }
//EMPTY #region PUBLIC_METHODS #endregion PUBLIC_METHODS #region PRIVATE_METHODS /// <summary> /// Handle the Left Controller input and put them in the Events /// </summary> void CheckLeftControllerInput() { BoolVariable temp; #region TRIGGER temp = LeftVariablesDictionnary.Get("TriggerIsDown"); if (!temp.Value && LeftController.GetHairTriggerDown()) { temp.SetValue(true); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftTriggerDown"); _leftEvent.Raise(); } else if (temp.Value && LeftController.GetHairTriggerUp()) { temp.SetValue(false); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftTriggerUp"); _leftEvent.Raise(); } #endregion TRIGGER #region TOUCHPAD temp = LeftVariablesDictionnary.Get("ThumbIsDown"); LeftThumbOrientation.SetValue(LeftController.GetAxis()); if (LeftController.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { temp.SetValue(true); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftThumbDown"); _leftEvent.Raise(); } else if (temp.Value && LeftController.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad)) { temp.SetValue(false); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftThumbUp"); _leftEvent.Raise(); } if (LeftController.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad)) { _leftEventBool = (GameEventBool)LeftEventsDictionnary.Get("LeftThumbTouching"); _leftEventBool.Raise(true); } else if (LeftController.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad)) { _leftEventBool = (GameEventBool)LeftEventsDictionnary.Get("LeftThumbTouching"); _leftEventBool.Raise(false); } #endregion TOUCHPAD #region GRIP temp = LeftVariablesDictionnary.Get("GripIsDown"); if (!temp.Value && LeftController.GetPressDown(SteamVR_Controller.ButtonMask.Grip)) { temp.SetValue(true); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftGripDown"); _leftEvent.Raise(); } else if (temp.Value && LeftController.GetPressUp(SteamVR_Controller.ButtonMask.Grip)) { temp.SetValue(false); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftGripUp"); _leftEvent.Raise(); } #endregion GRIP #region MENU temp = LeftVariablesDictionnary.Get("MenuIsDown"); if (!temp.Value && LeftController.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu)) { temp.SetValue(true); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftMenuDown"); _leftEvent.Raise(); } else if (temp.Value && LeftController.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu)) { temp.SetValue(false); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftMenuUp"); _leftEvent.Raise(); } #endregion MENU }