public void MouseInputUPRotatesCameraDown_Test(float value) { // setup float expected = value * 1f * SPEED; // since the desired rotation is clamped expected = Mathf.Clamp(expected, -60, 60); // because Unity returns rotations from 0 to 360 degrees expected = 360f - expected; // perform controller.Rotate(0f, value, 1f); // get Vector3 after = cameraTransform.rotation.eulerAngles; // assert Assert.AreEqual(expected, (float)Math.Round(after.x, 3)); }
private void Update() { // Camera Control float horizontalCameraRotation = Input.GetAxis("Mouse X"); float verticalCameraRotation = Input.GetAxis("Mouse Y"); m_tpsCam.Rotate(horizontalCameraRotation, verticalCameraRotation, 0.0f); float zoomDirection = Input.mouseScrollDelta.y; m_tpsCam.Zoom(zoomDirection); // Player Ship Control int shipMove = 0; if (Input.GetKeyDown(KeyCode.W)) { shipMove += 1; } if (Input.GetKeyDown(KeyCode.S)) { shipMove -= 1; } shipMove += (int)m_playerShipMovement.MoveState; m_playerShipMovement.MoveState = (ShipMoveState)Mathf.Clamp(shipMove, (int)ShipMoveState.Stop, (int)ShipMoveState.Fast); float shipRotateDirection = 0.0f; if (Input.GetKey(KeyCode.D)) { shipRotateDirection += 1.0f; } if (Input.GetKey(KeyCode.A)) { shipRotateDirection -= 1.0f; } m_playerShipMovement.Rotate(shipRotateDirection); }