public virtual void UpdateMovement() { // Do not apply input if we are showing a level selection display if (OVRMainMenu.sShowLevels == false) { bool moveForward = false; bool moveLeft = false; bool moveRight = false; bool moveBack = false; MoveScale = 1.0f; // * * * * * * * * * * * // Keyboard input // Move if (Input.GetKey(KeyCode.Space)) { moveForward = true; } // WASD /* * if (Input.GetKey(KeyCode.W)) moveForward = true; * if (Input.GetKey(KeyCode.A)) moveLeft = true; * if (Input.GetKey(KeyCode.S)) moveBack = true; * if (Input.GetKey(KeyCode.D)) moveRight = true; * // Arrow keys * if (Input.GetKey(KeyCode.UpArrow)) moveForward = true; * if (Input.GetKey(KeyCode.LeftArrow)) moveLeft = true; * if (Input.GetKey(KeyCode.DownArrow)) moveBack = true; * if (Input.GetKey(KeyCode.RightArrow)) moveRight = true; */ if ((moveForward && moveLeft) || (moveForward && moveRight) || (moveBack && moveLeft) || (moveBack && moveRight)) { MoveScale = 0.70710678f; } MoveScale *= DeltaTime; // Compute this for key movement float moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier; // Run! if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { Jump(); } if (DirXform != null) { if (moveForward) { MoveThrottle += DirXform.TransformDirection(Vector3.forward * moveInfluence); } if (moveBack) { MoveThrottle += DirXform.TransformDirection(Vector3.back * moveInfluence); } if (moveLeft) { MoveThrottle += DirXform.TransformDirection(Vector3.left * moveInfluence); } if (moveRight) { MoveThrottle += DirXform.TransformDirection(Vector3.right * moveInfluence); } } // Rotate // compute for key rotation float rotateInfluence = DeltaTime * RotationAmount * RotationScaleMultiplier; //reduce by half to avoid getting ill if (Input.GetKey(KeyCode.Q)) { YRotation -= rotateInfluence * 0.5f; } if (Input.GetKey(KeyCode.E)) { YRotation += rotateInfluence * 0.5f; } // * * * * * * * * * * * // Mouse input // Move // Rotate float deltaRotation = 0.0f; if (AllowMouseRotation == false) { deltaRotation = Input.GetAxis("Mouse X") * rotateInfluence * 3.25f; } float filteredDeltaRotation = (sDeltaRotationOld * 0.0f) + (deltaRotation * 1.0f); YRotation += filteredDeltaRotation; sDeltaRotationOld = filteredDeltaRotation; // * * * * * * * * * * * // XBox controller input // Compute this for xinput movement moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier; // Run! moveInfluence *= 1.0f + OVRGamepadController.GetTriggerLeft(); // Move currForward = DirXform.TransformDirection(Vector3.forward * moveInfluence); //forwardDirHistory.Enqueue(currForward); //driftForward = forwardDirHistory.Dequeue(); forward = currForward; if (DirXform != null) { if (OVRGamepadController.GetAxisLeftY() > 0.0f) { MoveThrottle += OVRGamepadController.GetAxisLeftY() * DirXform.TransformDirection(Vector3.forward * moveInfluence); } if (OVRGamepadController.GetAxisLeftY() < 0.0f) { MoveThrottle += Mathf.Abs(OVRGamepadController.GetAxisLeftY()) * DirXform.TransformDirection(Vector3.back * moveInfluence); } if (OVRGamepadController.GetAxisLeftX() < 0.0f) { MoveThrottle += Mathf.Abs(OVRGamepadController.GetAxisLeftX()) * DirXform.TransformDirection(Vector3.left * moveInfluence); } if (OVRGamepadController.GetAxisLeftX() > 0.0f) { MoveThrottle += OVRGamepadController.GetAxisLeftX() * DirXform.TransformDirection(Vector3.right * moveInfluence); } } // Rotate YRotation += OVRGamepadController.GetAxisRightX() * rotateInfluence; } // Update cameras direction and rotation SetCameras(); }