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:

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?

• Presumably, @CraftyMaelyss, you started by searching for how to use an axis like a button in Unity, and followed some of the solutions already published online? Where did you run into trouble? Mar 2 '20 at 12:19
• Mainly from trying to map the arrows like individual buttons. On the wiki page for Unity, where it talks about gamepad layouts, the Dpads are both axis, like the analog controllers. I did try this method, but it caused errors and every error I fixed, resulted in more popping up: answers.unity.com/questions/376587/… I'm really stuck here, as this is crucial to gameplay :( Mar 6 '20 at 14:21
• If you show us what you did and the errors you got, we can help you solve them Mar 6 '20 at 14:31

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.

The parts we specifically care about are these

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

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

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.

• 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. Mar 6 '20 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).