How can I use Gamepad in the UI Widgets in Unreal Engine 5?


AUTHOR: Carlos Castro Unreal Engine 5.1

For this week I wanted to use the gamepad in the different widgets we had in our game. I wanted to be able to use sliders, to use the buttons, and to be able to use them without issues.

I started doing research about this topic, watching YouTube videos, looking at the documentation, and trying to understand how this process could work. In the end, I saw that all the implementations were very complicated, that I needed to change the whole UI to create some buttons blueprints creating my own event tick function, and another method that I didn’t want to implement. Since this had to be done in less than a week I needed a simple and effective process to make it. 

By doing that whole research I saw a very particular gamepad function called “Set Focus” This function I saw in one of the unreal engine forum chats and I wanted to use that in my game to identify the gamepad inside the UI and be able to navigate the UI using the gamepad.

The way I could make the gamepad work in the UI widgets consisted of multiple steps. 

The first step is in all the buttons or sliders inside the UI Widget you need to have the “Is Focusable” to be true. This is going to allow the gamepad to identify if that can be focused or not. This boolean is in the Interaction section of any button or slider. 

Then you can create a custom event to start the gamepad. In that custom event, you need to pass a button (It can be any button you have in the widget) and set it to focus. This button will be the start game focus when you are on the widget during gameplay.

Then you are going to need to create two variables. These two variables must be of type Color Linear Structure. One of those variables is going to have the hover color and the other is when the button is not hovering. 


Then on the event tick you can create an array with all the buttons that are on the widget then for each button you are going to check if has keyboard focus. If it has keyboard focus then you want to pass the hover color and adjust the background color of that specific button. If it’s false then you want to pass the second color that is when you are not hovering over that specific button. 


The last step is on the construct event you need to call the start gamepad in order to make it work. 


With these simple steps, the gamepad is going to work perfectly on the UI Widgets.

The last thing to keep in mind is if you are using sliders in the widget be sure to leave enough space between each slider in that way the set focus is going to work perfectly. 


I hope this works for everyone who reads this.

Leave a comment

Log in with itch.io to leave a comment.