Menu Selection with Gamepad and ShooterGame Example Pause Menu


I currently have a Main Menu on game startup which works with a mouse cursor and selection. Ultimately I want there to be no mouse control, just selection through a gamepad but I’m finding it difficult to set up.

I found within the ShooterGame example that when playing with a gamepad it has the exact same controller setup for a menu that I want in my game although I cannot find where it is linked. I went into the PlayerPawn (or it may have been PlayerCharacter) and there weren’t any blueprint scripts in there. I clicked on Show Inherited which displayed a long list of things that the class is taking from but when I try to find references to where they are it says that there are no references - what?!

Couple of things then really: 1) Can anyone suggest a good way to setup a gamepad operated menu and 2) can anyone tell me how to access the menu funtions within the ShooterGame example?

Thanks ya’ll

Hi Omnicypher, could you elaborate a bit more about this solution? i understand how it should work, but i couldn’t find a way to implement it in UE4. Thanks!

for a simple example, lets just focus on a single dimension, like a television. a TV has a spectrum of channels, with the currently selected channel representing a position in that spectrum. you can change channels by increasing the channel position. but if you want to increase the channel over time, by holding the up button, you need to use velocity to change the position. so you could multiply velocity by the movementInput:

every tick:
position = position + velocity * movementInput * DeltaSeconds;

but this gives an immediate acceleration, which might work well for joysticks, but doesn’t work so great for D-pads. so if you want a smooth increase in speed over time, you need to use the movementInput to adjust acceleration, rather than velocity:

every tick:
velocity = velocity + movementInput * Acceleration * DeltaSeconds;
velocity = clamp( velocity, -maxVelocity, maxVelocity );
position = position + velocity * DeltaSeconds;

then when you want to update the current menu, you can cast that position float into an int to access an array or to use it in a switch case or read from a spread sheet. either way, the information you access from the array or switch case can initialize the proper input handling delegates and add the proper menu widgets to the screen. if you are using canvas, it can initialize the arrays that the hud uses to define a menu layout and data.

once you get this working for a single dimension, you can add as many dimensions as you want, for things like tabs, scrolling offsets, soundVolumeSliders, etc… any spectrum that you would want to traverse with a smooth acceleration can use this system. you could put all of this in a MenuMovementComponent, or just add the code directly to your HUD.