How to capture D'Pad in the same format as the axis?

Hi guys
Would anyone know how to tell me how to capture the values of the DPad so that they are similar to the values coming from the axis?

Not sure what yo mean by similar values. Both the sticks and the dpad give the same ([-1…1],[-1…1]) values.

As far as gamepads go, you can read the dpad as a whole which gives a Vector2 just like the stick. Or if you’re looking for individual axes, the dpad has an x and y axis like the sticks.

// Vector2.
Gamepad.current.dpad.ReadValue<Vector2>();
Gamepad.current.leftStick.ReadValue<Vector2>();

// X and Y axis.
Gamepad.current.dpad.x.ReadValue<float>();
Gamepad.current.dpad.y.ReadValue<float>();
Gamepad.current.leftStick.x.ReadValue<float>();
Gamepad.current.leftStick.y.ReadValue<float>();
1 Like

@Rene-Damm
Thank you very much, it worked, but the angles captured by d’pad are only in variations of 45 degrees.
Is there a way to take all possible degrees to form a circle?

Unfortunately no. Given the dpad is only four buttons, it can’t by itself produce more nuanced angles. They can be artificially produced by interpolating between the angles over time but there’s no support for this out-of-the-box ATM and it tends to produce sluggish behavior.

1 Like