Identifying if the player is using a controller Issue Updating controlls UI In real Time


Description of the issue:

The issue that I was having is that I wanted to update in real-time if the player is using an XBOX controller or if is using a keyboard and mouse.

On the other hand, when the player changes the type of controller, I wanted to be able to notify the player to update the respective UI image in real-time.

I made a lot of research about this topic but there is not any clear information on how to make it if you are using the Unreal Engine 5 Input Mapping Context.

Solution:

On the player blueprint, I decided to create a Boolean variable and then I wanted to check every time the player presses any key at that point I don’t care if is a keyboard input or a controller input. Then I found a very good function to use which is “is Gamepad Key” This function will return true if the key that was used is from a gamepad. Then if that returns true, I decided to update my Boolean variable.

On the other hand, in the UI I created a Boolean variable for each control type that I had. Then I was able to identify if this Boolean is true or not. If the Boolean from the player blueprint is true and then if the Input Mapping Context is (The name of the input mapping context) then I was to update the image to be a control image, if this is false then I want to keep using the keyboard UI image.

It was tricky to make it work, but in the end, this solution is perfect to update the UI image or textures in real-time using Unreal Engine 5 and also using different types of Input Mapping.

Leave a comment

Log in with itch.io to leave a comment.