I've looked around and had no luck, so I want to ask here. I'm using an XBOX ONE controller for my game, I've set up the input, however my issue is with the Dpad itself.

Below is an example of how I want to implement the Dpad, but with actions instead of weapons: enter image description here

but the problem is, I can't find any tutorials to explain how to actually go about setting something like this up. Initially, I tried going into the Project Settings, changing the Input but the Dpad is limited to axises and won't actually work as individual buttons.

What would be the best way to get the Dpad to work individually as buttons?


2 Answers 2


but the Dpad is limited to axises and won't actually work as individual buttons.

This is by design. If you want to do something specific when a D-pad direction is pressed, you can do so the same way that you would detect if a player had pushed their thumbsticks up, or left, or right, or down.

You need to check what direction, if any, each dpad axis is pointing and then do something.

This unity answers thread is helpful

The parts we specifically care about are these

float x = Input.GetAxis("DPad X");
float y = Input.GetAxis("DPad Y");

IsLeft = false;
IsRight = false;
IsUp = false;
IsDown = false;

//Adjust these numbers to taste
if (x == -1)
    IsLeft = true;
else if (x == 1)
    IsRight = true;

if (y == -1)
    IsDown = true;
else if (y == 1)
    IsUp = true;

The one caveat is I'm not 100% sure if the names of the axes are correct here, you'll have to check your input settings. But there is no "Press dpad button left". You need to check the axes to see if the user pressed it far enough left, right, up or down.

  • 2
    \$\begingroup\$ You probably don't want to compare floats for exact equality without some rounding. Otherwise x = 0.9999f would be considered "not right". Instead, consider using a range, optionally with some hysteresis for stability. \$\endgroup\$
    – DMGregory
    Mar 6, 2020 at 17:05

The new input system offers the option to handle a directional pad as both a two-axis analog input or as four separate digital button inputs. And if necessary even both at the same time. The class DPadControl implements both Vector2Control itself and also has four ButtonControl members for the four directions. So you can access its state both like this:

if (Gamepad.current.dpad.x > 0f) {
    // player currently holds right

or like this:

if (Gamepad.current.dpad.right.wasPressedThisFrame) {
    // player just pressed right

You can also use both variants when you assign inputs to actions in the Input Actions asset (which I would actually recommend).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .