Hi! How can I implement an input type detection system in UE4.27? I want to make it so that when using a gamepad, the action icons change and the mouse cursor is hidden.
HI @TheStad1_b09 ,
I’ve been doing some research, and in version 4.27 you can use CommonUI to do what you lneed . Here’s a step-by-step tutorial on how to set it up.
-
Go to the top menu, select Edit then Plugins, and enable CommonUI(the engine will restart)
-
Import the icons you want to use for your project (I used some sample icons)
-
Create a Data Table (right click and select Miscellaneous and select CommonInputActionDataBase) that will contain all the input actions you want to use in your game or project
-
Open the Data Table, and at the top, click the ‘+’ button to add a new row.
-
Then, in the bottom section, you can customize the input for each device type. Under “Keyboard Input Type Info” and “Gamepad Input Type Info”, you’ll see fields where you can assign specific keys or buttons( this is where you define what key corresponds to this action)
-
You have to create two Blueprints ,one for gamepad input and one for keyboard input.
Right-click in the Content Browser and select Create “Blueprint”, at the bottom in the ‘All Classes’ search bar, look for CommonInputBaseControllerData. Duplicate this blueprint and you will have two Blueprints: one named BP_GamePadInput and the other BP_KeyBoardInput.
-
Inside the Gamepad Blueprint, you need to assign the corresponding buttons , they must match the ones you previously set in the Data Table. The important part here is to change the “Gamepad Name” to Generic.
To add the button icons, look for the Input Brush Data Map section and use the ‘+’ button to add entries for each input action you want to support (you have to do the same inside the BP_KeyBoardInput)
-
Go to Project Settings and scroll all the way down until you find the Common Input section.
Under PC or Windows, assign your Blueprints to the “Controller Data” fields. Make sure that the Default Gamepad Name is set to “Generic” ,(this should match the Gamepad Name you used in your BP_GamePadInput Blueprint).
-
Aso in the Project Settings go to the General Settings ,in Game Viewport Client Class, select “CommonGameViewportClient”
-
In the top-left panel , add one CommonActionWidget for each input action you want to display in the widget. Then, on the right side, select your Data Table and choose the corresponding Row Name for that action
11.Finally, go to your BP_MainCharacter and add the widget to the player’s viewport
I hope this helps, and that I didn’t forget anything! If you have any questions, feel free to ask!
I’m also including Epic’s official documentation on how CommonUI works
Thanks buddy!