public virtual void UpdateMovement() { if (HaltUpdateMovement) { return; } bool moveForward = Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow); bool moveLeft = Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow); bool moveRight = Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow); bool moveBack = Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow); bool moveUp = Input.GetKey(KeyCode.T); bool moveDown = Input.GetKey(KeyCode.G); bool zoomIn = Input.GetAxis("Mouse ScrollWheel") > 0; bool zoomOut = Input.GetAxis("Mouse ScrollWheel") < 0; MoveScale = 1.0f; if ((moveForward && moveLeft) || (moveForward && moveRight) || (moveBack && moveLeft) || (moveBack && moveRight)) { MoveScale = 0.70710678f; } MoveScale *= SimulationRate * Time.deltaTime; // Compute this for key movement float moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier; Quaternion ort = (HmdRotatesY) ? CameraController.centerEyeAnchor.rotation : transform.rotation; Vector3 ortEuler = ort.eulerAngles; ortEuler.z = ortEuler.x = 0f; ort = Quaternion.Euler(ortEuler); if (moveForward) { MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * Vector3.forward); } if (moveBack) { MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * BackAndSideDampen * Vector3.back); } if (moveLeft) { MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.left); } if (moveRight) { MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.right); } if (moveUp) { MoveThrottle += ort * (transform.lossyScale.y * moveInfluence * Vector3.up); } if (moveDown) { MoveThrottle += ort * (transform.lossyScale.y * moveInfluence * BackAndSideDampen * Vector3.down); } if (zoomIn) { Camera leftCamera = CameraController.leftEyeAnchor.GetComponent <Camera> (); Camera rightCamera = CameraController.rightEyeAnchor.GetComponent <Camera> (); if (leftCamera.fieldOfView > 2) { leftCamera.fieldOfView -= 2; } if (rightCamera.fieldOfView > 2) { rightCamera.fieldOfView -= 2; } } if (zoomOut) { Camera leftCamera = CameraController.leftEyeAnchor.GetComponent <Camera> (); Camera rightCamera = CameraController.rightEyeAnchor.GetComponent <Camera> (); if (leftCamera.fieldOfView < 99) { leftCamera.fieldOfView += 2; } if (rightCamera.fieldOfView < 99) { rightCamera.fieldOfView += 2; } } //toggle if (Input.GetKey(KeyCode.R) & buttonPushed < Time.time - 0.2f) //show hide ribbons { if (addAtoms.ribbonShowing) { addAtoms.ribbonShowing = addAtoms.resetProtein("ribbons"); } else { addAtoms.ribbonShowing = addAtoms.showMode("ribbons"); } buttonPushed = Time.time; } if (Input.GetKey(KeyCode.N) & buttonPushed < Time.time - 0.2f) //menu { source.PlayOneShot(menuToggled, 0.5f); menu.enabled = !menu.enabled; //hide show menu buttonPushed = Time.time; } if (Input.GetKey(KeyCode.V) & buttonPushed < Time.time - 0.2f) //center { addAtoms.setPosition(ort * Vector3.forward * 30 + this.transform.position); //centers the atoms infront of the user buttonPushed = Time.time; } if (Input.GetKey(KeyCode.L) & buttonPushed < Time.time - 0.2f) //screenshot { Application.CaptureScreenshot(Application.dataPath + "/Screenshot.png", 4); buttonPushed = Time.time; } if (Input.GetKey(KeyCode.X) & buttonPushed < Time.time - 0.2f) //reset center { addAtoms.resetTarget(); buttonPushed = Time.time; } if (Input.GetKey(KeyCode.Z) & buttonPushed < Time.time - 0.2f) //lock target { addAtoms.lockTarget(); buttonPushed = Time.time; } if (Input.GetKey(KeyCode.P) & buttonPushed < Time.time - 0.2f) // change driver { bool newDriver = false; foreach (var user in trackedUsers) { if (user == null) { continue; } if (user.IsTracked) { if (driver == user.TrackingId) { newDriver = true; continue; } if (newDriver) { setDriver(user.TrackingId); newDriver = false; break; } } } if (newDriver) //iterate once more if a new driver wasn't selected { foreach (var user in trackedUsers) { if (user == null) { continue; } if (user.IsTracked) { if (newDriver) { setDriver(user.TrackingId); break; } } } } } moveInfluence = SimulationRate * Time.deltaTime * Acceleration * 0.1f * MoveScale * MoveScaleMultiplier; }
private void resetTarget() { addAtoms.resetTarget(); }