InputSystem
InputSystem copied to clipboard
How to get axis from a gamepad stick and mouse?
I want to move the camera with the right stick of the gamepad and mouse. Before, with the old system I used Input.GetAxis("Mouse X"); and Input.GetAxis("Mouse Y"); to move the camera with the mouse. Is there a similar way to do that with the sticks?
I know this isn't really an issue, but I don't find the way to do it
I would like to know as well.
Tests for mouse and keyboard worked for me, GamePad didn't seem to react to SteamController.
using UnityEngine.Experimental.Input;
Returned float
Debug.Log("MouseX: " + Mouse.current.position.x.ReadValue());
Debug.Log("MouseY: " + Mouse.current.position.y.ReadValue());
returned Vector2
Debug.Log("Mouse position: " + InputSystem.GetDevice<Mouse>().position.ReadValue());
should return float, but I had Steam Controller only so I couldn't test this.
Debug.Log("GamepadX: " + Gamepad.current.leftStick.x.ReadValue());
Debug.Log("GamepadY: " + Gamepad.current.leftStick.y.ReadValue());
Keyboard test
if ( InputSystem.GetDevice<Keyboard>().spaceKey.wasPressedThisFrame ) {
Debug.Log("Space pressed");
}
Edit: I had not added GamePad to my input manager as preference in project settings and that was why I didn't get any inputs there.