Best way to use XBox Buttons (or other joystick buttons) for menus etc? Best Setup.

I’m beginning to get my game working w/ a joystick. I have an XBox controller hooked up to the computer, figuring most modern controllers will have similar buttons, but I’m trying to figure out how best to USE the controllers.

That is, the game will have touch mouse interfaces, which are pretty straight forward since the user just has to click.

But for the joystick, there’s the A/B/X/Y buttons, the two joysticks and the DPad, plus the triggers and bumpers on the top, both Left and Right of each.

Now my game is a top-down RPG of sorts, like Secret of Mana, so ABXY are being used for attacks etc. The joysticks are for movement and camera movement.

What’s the best way to do yes and no selections for menus? Currently I’m using the DPad for menu movement, along with the bumpers for menu-screen changes, and the A/X button for “YES/NO”.

I have zero experience with modern consoles, so I don’t know how they work for this, and I’ve so far been unable to invite myself over to af fiends house who has a modern console :slight_smile:

So, what are the thoughts? What makes sense, and what, I suppose most importantly, do “real” games do?

What you have now is fairly common from my experience. Two things did catch my eye though, firstly being that it seems more common to use the A and B buttons (XBOX 360) for accept / cancel buttons, and the other is constraining the player to using nothing but the d-pad for the menu control; why not allow them to use the joystick as well?

I was thinking about letting them use the joystick as well as the dpad, since I found myself automatically doing that even though I programmed it and knew it didn’t work! However, I need to find a way to ensure that each frame doesn’t get the input that the “right” direction is being pushed. With the buttons I have the luxury of GetButtonDown, but the Axis is a number that spans many many frames.

A trigger could work, but I think I’d need to do a lot of testing to know how to make the “off-trigger” feel right. I really just need to play an XBOX! :smile:

You could do something similar to the following, to make sure that your axis check isn’t done every frame.

// Class field
private float SelectionDelay = 0.25f;
private float DelayTimer = 0.0f;

// Somewhere in your update code
if (Time.time < this.DelayTimer)
                        return;

YourProcessingCodeOrMethod()

this.DelayTimer = Time.time + this.SelectionDelay;

I tried that briefly for another thing with the controller earlier, but it’s too rigid.

I was thinking something like this:

var rightPressed : boolean = false;

function Update(){
     if (Input.GetAxis("Horizontal") >= 0.95  !rightPressed)
     {
          rightPressed = true;
          DoActionNow();
     }
     if (Input.GetAxis("Horizontal") <= 0.2  rightPressed)
          rightPressed = false;
}

It certainly used to be the case - not sure if it still is - that passing certification on Xbox required you to use the A button for ‘accept / forward / yes’ and the B button for ‘cancel / backward / no’, such that you could walk up to a game on its title screen and just hit the A button repeatedly to start playing, or hit B repeatedly on any menu screen to get back to the title screen.

I would take a look at popular games of the same genre and keep close to their input scheme. The more familiar your setup “feels” to a new gamer the lower the entry difficulty will be. Like other people wrote, for me using “A” as accept and “B” as cancel button is a non-written standard these days for example.

Ah very helpful. I’ll start re-doing mine for this. I also realized last night that it may be easier to have selected “Yes” and “No” inputs so the user must DPad over to the “Yes” and then press A. Is that accurate, or would the simple “Do you want to enter the dungeon?” With no “Yes” or “No” text be better?

It’s hard to know without a more full understanding of your game design, but the former sounds very bad to me. Not only are you turning a simple binary choice into something that requires two button presses (Dpad + A to select), but you’re also causing the A button to invert its meaning, and adding redundancy to the B button.

I would go with a ‘Do you want to enter the dungeon’ prompt with ‘(A) Yes’ and ‘(B) No’ text underneath - nothing selectable, just static text to tell the user which buttons to press.

For entering dungeons I’ve now just begun to use the trigger button which works for pickups, enemy looting, talking to NPCs and entering buildings/dungeons, depending on what’s close to the player.

I want to avoid people accidentally deleting games or accidentally doing things that are kind of big choices, and I think if I had A=Yes on the confirmation screens, people may accidentally double-tap or press the wrong button. If they have to first joystick or dpad right and then tap A, it ensures to a greater degree they actually want to do the action. Especially for deleting games.

While testing the game this setup does seem to feel more natural to me, of course having never played XBox games. This setup also works well with keyboard, since the intent is to allow keyboard/mouse control OR joystick control for PC/Mac installs, and ultimately touch control for mobile.

All controllers are different. I’d highly get CInput from the Asset Store, which allows users to map controls at run-time and stores them.
What may work on your 360 controller, won’t work on many other controllers, I know this from experience. Always allow users to map controls themselves.

Yes, I agree that’s better and actually does match what’s more typical on AAA games.

+1

I ended up creating a simple wrapper on top of cInput to allow generic gamepad support. I have several presets (xbox, ps3, etc) and will end up also allowing the player to map whatever they want. It allows me to reference input names like “Lower face button” rather than have to call it “A” or “X” or whatever, which reads better in the code. With the presets, it means that players using common controllers don’t have to do any work to get playing, yet it’s flexible enough to support weird joysticks, off brand gamepads, custom-made Arduino controllers, guitar controllers, and so on.