- Home /
Using DPad/Joystick in "new" InputSystem as digital rather than analog
I'm using the InputSystem, previously called the New Input System, and have an action for Movement with bindings available for a gamepad joystick, and for keyboard WASD (Attached in picture). The input is stored in a Vector2 for use in FixedUpdate. Input from WASD is digital 0, 1 or -1, but input from the dpad is analog from anywhere between -1 to 1. I would like the dpad to be output as digital so movement is the same no matter the control type choosen.
Here is a basic of what I have:
LevelInputActions controls;
Vector2 inputMovement;
private void Awake()
{
controls = new LevelInputActions();
controls.PlayerControls.Movement.performed += ctx => inputMovement = ctx.ReadValue<Vector2>();
controls.PlayerControls.Movement.canceled += ctx => inputMovement = Vector2.zero;
}
private void FixedUpdate()
{
print(inputMovement.x);
}
Is there an easy way to have it read the inputs the way I want? Or do I have to just convery the analog input from dpad to be a digital -1/0/1 manually? I hope this makes sense lol, thank you!
Answer by chrisf112233 · May 07, 2020 at 01:52 AM
Figured it out...
For the action, click the plus and choose add 2D vector compsite, and set each up/down/left/right as stick/[direction]