InputSystem icon indicating copy to clipboard operation
InputSystem copied to clipboard

How to get axis from a gamepad stick and mouse?

Open EGGamer opened this issue 7 years ago • 2 comments

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

EGGamer avatar Dec 29 '18 14:12 EGGamer

I would like to know as well.

PlanetVaster avatar Jan 01 '19 23:01 PlanetVaster

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.

h8672 avatar Jan 10 '19 12:01 h8672