To close a widget you have to remove it from the viewport (with the node called “Remove from Parent”.
Just save the return value from “Create Widget” in a variable and use that to remove it when you press your key.
And for the focus. There are events to bring a widget into focus. Like “Set Focus UI” (something close to that. It’s not quite the exact name). For this you will need again the widget reference.
yes, i need it, because i want that the player could open the menu pressing the “p” key and that he could close it pressing again the “p” key but i don’t know how to manage the “p pressed” on the UMG blueprint
I can’t do like that because when i call the Widget in the level blueprint the game stop read “level blueprint” and start reading the “umg blueprint”, so if i control that the user pressed again the p in the level blueprint the game will do nothing, that’s my problem :\
Does the “Set Input Mode Game and UI” allow the “p” event to fire?
It says that the if the input doesn’t get handled by the widget then the Controller gets a chance to
The real problem was that when i create the UMG i put the “pause game” node, and it blocked the level blueprint script. Now i can close the menu with “p key” but how to stop the game run when the umg is open?
Ok i found how to control if the user press the p key during UMG, i need an event that could control that script, like “when a key is pressed” or something like that. Any suggestion how to do that?
Using that nodes i can control when the user press the “p key” in the umg, but i can’t use event tick because it fires always, so when i press the “p key” for the first time the game open the menu ( i can see it) but the game close it at the same moment. So i need another event, but i can’t find a solution
The variable widget is simply of the type “Widget”. Please also notice that the checkbox “Execute when paused” inside of the “Event P” is enabled. First you create the widget, save it in a variable and then toggle between adding it to the view port and removing it from the same. A FlipFlop simply switches between A and B every time it’s called.
Are you using the Unreal function to pause / freeze the game? Because if you do your input events to the controller will be frozen as well unless specified otherwise in the variable defaults.