Hold and release button to control menu

Hello fellow UE4 users. I am looking to be able to open a menu by holding the R1 gamepad button and then closed the menu when the button is no longer held. I am trying set up a hotkey menu for abilities in game. So in battle I could hold the shoulder button, the menu would open, then press triangle, square, circle to use ability and then it would close when i released the shoulder button. Any help would be greatly appreciated!!! I just cant figure out the hold an release part.

get the key event, then from the pressed do → set a bool variable to true which will execute a while loop
then from the released exec set the bool variable to false, this will also go to the exec of the while loop. in the condition hookup your bool variable. then from the loop body you can do what you want.

Thank you for such a quick response. Though I am still confused as I am more of a visual learner. So would it be something like this?

just use one while loop. both the set variables’s exec are gonna go into a single while loop.

An error regarding an infinite loop was caused and everytime I press the button it closes the game, any suggestions?

can you give me pic of what you are doing.

Yes this is being done in the third person character blueprint.

And this is the error I recieve:

I have the loop body connected to my create widget node. sorry i didnt show that.

I think here you just need to add the ’ Remove from parent’ node on the ‘Release’ Event with the bool and the Create Widget → Add to viewport, would only go on the Pressed Event

That is what I was starting to do just now, but it is asking for a target on the remove from parent. Not sure what to do here?

That would go onto the Return from the Create widget node

i think just adding a remove from parent on the completed might solve the problem.

should this be implemeted in my character BP or my widget BP? As of right now it is in my character BP and it is asking for a target to be connected to the remove from parent node.

I finally figured it out! well at least it works so far without tying in hot keys:

It seems simple, but I was probably over complicating things mentally.

Very good. As far as where to implement the widget, that’s always a tricky question to solve. There are many variables that get involved to really begin or even try to narrow the question down.

Starting with like -

  • will it have data pertaining to the character or character’s
  • another actor; a set of actors;
  • to an actor that can be destroyed;
  • does it re-spawn; Does the data reset on an actor re-spawning
  • does the data need to be constant throughout a level or entire game session