void Update() { currentInput = new FrameInput(); //TODO sensitivity values //take input for player if (Input.GetKey(KeyCode.C)) //when a key is pushed, reset the mouse { ResetMouseOrigin(); } if (Input.GetButtonUp("FlightMode")) //change from ACRO to STAB mode { flightMode = flightMode == ControlMode.ACRO ? ControlMode.STAB : ControlMode.ACRO; } if (Input.GetButtonUp("BaroMode")) //toggles barometric mode { baroMode = !baroMode; } currentInput.BaroMode = baroMode; currentInput.FlightMode = flightMode; //Throttle and Yaw currentInput.Throttle = Input.GetAxis("Vertical") * ThrottleSensitivity; currentInput.Yaw = Input.GetAxis("Horizontal") * YawSensitivity; //Roll and Pitch inputs if (inputDevice.Equals(InputDevice.Keyboard)) { Vector3 mousePosition = Input.mousePosition; //TODO can be uneven if mouse origin is not very centered currentInput.Roll = Mathf.Clamp((mousePosition - mouseOrigin).x / Screen.width * 2, -1, 1) * RollSensitivity; currentInput.Pitch = Mathf.Clamp((mouseOrigin - mousePosition).y / Screen.height * 2, -1, 1) * PitchSensitivity; } else if (inputDevice.Equals(InputDevice.Controller)) { currentInput.Roll = Input.GetAxis("PadRoll") * RollSensitivity; currentInput.Pitch = Input.GetAxis("PadPitch") * PitchSensitivity; } }
void Update() { bool isControllerKnown = false; activeDevice = InputManager.ActiveDevice; foreach (InputDevice dev in playerControllers) { if (activeDevice.Equals(dev)) { isControllerKnown = true; } } if (!isControllerKnown && activeDevice.AnyButton.WasPressed) { playerControllers.Add(activeDevice); SpawnPlayer(activeDevice); } }