Download

Newbie Question Of The Week: UMG with gamepad

Hi guys,
I have another newbie question for anyone willing to help. I want to create a system that pauses the game and goes to a menu at the touch of a game pad button. When the button is pressed again, I want the menu to close (think console inventory menu). I’m able to do the first part, but I can’t seem to remove the widget at a button press. I know there’s a lot of tutorials about how to do it with a mouse - and I can do those - but it’s different with a game pad. I know there’s video tutorials about creating main menus, but they don’t really cover what I want because they use ‘event begin play’ which, to my limited knowledge, I don’t think I need. I have also seen other posts here asking the same thing, but honestly the answers use terminology that leaves me feeling a little stupid because I don’t understand it.

So please, talk to me as if I’m Jon Snow from Game of Thrones. I know nothing.

Thanks in advance!

Last I check game pad in umg requires a lot of work as your basically making a state and changing it based on button press in current state.

Imagine a enum list of a basic menu pause-> opens pause menu. Commands listed 1. Un pause 2. Quit to menu 3. Quit game

When umg opens it would assume you are on resume. As menu enum would be wuick. Down button would on press switch on enum which would then set enum to quit to menu. If pressed again switch on enum to change enum to quit game.

I’m not sure what your looking for but likely you’d want to do somthing like this on a grid basis of its inventory, say 3 rows 8 collums so you can move around the grid switching based on the enum. A lot of work.

Hope this help a little

Hi,
I can’t help but think UE4 would have made a similar system to ‘add widget to viewport’ with a simple change ‘remove widget from viewport’ with a reference to what widget to remove. Would have been far more straightforward XD

Well, my knowledge may be lacking, but I’m not put off by hard work :slight_smile:

Thanks for boiling it down for me, I’ll look into the solution you suggested and hopefully wrap my head around the concept enough to get something usable. Thanks for pointing me in the right direction :smiley:

Widgets can be a pain mostly depending on where you are adding them.

I highly recommend using player controller events because if you add them in say a item blue print hen they will end up belonging to the item so the item is destroyed the reference can be lost and it is then stuck on screen.

But if your event is called in controller to add the widget you can set the player admits owner and hold the reference so even if the player dies etc they still have the reference because your not removing the controller ever.

Thanks, I’ll definitely keep that in mind :slight_smile:
I’ve had some trouble getting my head around some of the concepts of UE4, but widgets are definitely my least favourite aspect so far. They just seem needlessly complex!

It’s s big engine! Needs to have these things in order to be more then simple buttons for the big developers :slight_smile:

Implementing Gamepad support in UE4 with your game through blueprints can take a lot of work.
here is something i have compiled for you:
First go into preferences > Input > Create a Pause input with the buttons you would like to pause the game with.
aacd954b71f00c29038c531ea9b5c183b7ab1600.png

Then go into your character BP and create a Boolean, you can call it whatever you like but i felt ‘Is Game Paused?’ Sufficient. then follow the blueprint.

Then Add this to your Menu BP, to enable just pressing a button to unpause at anytime.
5f7a4db45ccba126fba9cf6120ab7ae7b28b5a4b.png
This should Resolve your issue.

Hi,
thanks so much for the example, I can follow everything but the OnPressed(Button_8). I hope it doesn’t sound too stupid, but I’m not sure what that input is ^^;

I’m betting that is an unnamed button in a umg.

Wow, I was overthinking it, I thought it was some button on the game pad. Facepalm moment.

It is just simply a button in the pause menu which will un-pause the game.
Here is an updated version for you if you want to simply close the menu as easy as opening it:

By pressing the pause button on the gamepad, xbox one controller or Keyboard (Whatever button you have designated) It will close the menu as well without needing to select anything.
5f7a4db45ccba126fba9cf6120ab7ae7b28b5a4b.png

I Suggest you use this one.

Ah, that’s exactly what I was looking for! Thanks so much for taking the time to prepare it for me, I really appreciate it :slight_smile:

No Problem Buddy, i’m here to help

Hi,
I seem to have come across a problem. I assumed all the blueprints were to go in the character event graph, but remove from parent won’t work there. I tried it under the widget’s event graph, but the bool isn’t there. Am I missing something?

i have updated the blueprint for you, please note that these BP’s below are meant to be added to your Pause menu Ui BP.
I Hope This Helps.

Well, that fixed the boolean problem, but unfortunately it created a compilation error. 'Third Person Character does not inherit from ‘player controller’ (cast to thirdpersoncharacter will always fail) ^^;

Keep in mind that where i have CastTo_ThirdPersonCharacter This is just the Character_BP for my Character in My Game. it may be different to yours in which you reference the player controller.

Yours might be Cast to > FPSCharacter or John or anything you have named your character BP.

If this does nothing then try changing Get Player Controller to Get Owning Player

I was using the exact same naming conventions, but neither approach seemed to be working for me. I did, however, find a solution for anyone struggling with a similar thing. Although I have still yet to turn it into a proper functional tabbed menu and inventory system, the attached blueprint will at least bring up a pause menu when pressed and close it when pressed again. Please note that on the ‘create widget’ node, a line must be pulled from return value and then promoted to a variable :slight_smile:

Thank you for all your help, it is very much appreciated!