How to make a disappearing widget

I am trying to make a popup widget that will display on the HUD whenever the player picks up a key to open the door to the next section of the level. The only way I can imagine doing this is with casting it to the third person character and use the event tick to check if the player has picked up the key. I then use a branch to check a Boolean and then display it to the HUD and after a delay, remove it.

My issue is with casting it to the third person character as it needs a valid object.

If you can think of any solutions, please let me know.

Or…

Use your player controller, because player controller always exist on a client…
Your “popup” widget should contain your text like “You got KEY” and add a fadein/fadeout animation into widget…
in your widget constructor (that means when widget created) start this animation and use animationends event (bind a custom event to this dispatcher) so you definitly will know when animation ends… when animation ends… just call remove from parent, which will destruct that widget…

In gameplay code when player pickup a key, you should get player controller then create / add this widget to viewport and everything else (like removing fade out) should done automatically if you use only one animation (which for example fade in from 0sec to 1 sec, keep visible 1sec to 3sec, fade out 3sec to 4sec)

If you are done with this you can think how you extend this with with vertical panel (so you can add multiple animated widgets) etc. :slight_smile:

I have made pop-up widgets for similar uses in my game. What I do is “create” and add the widget to viewport in an empty actor I use to store things I would like to reference in my level because you can’t cast to the level blueprint (unfortunately). I drag that empty actor into my level. Then I will cast to the “empty” actor from my character blueprint or item blueprint, whichever you choose to run your script through using a “get all actors of class” which there should only be one of these “empty actors” in your level, create a reference of that actor to be used whenever I like. So when the character “picks up” an item you grab the reference to the empty actor, get the “widget” it created and set visibility to “visible”, once you are done doing whatever you wanted, run a delay and then set widget visibility to hidden. Works well for me, this way you only create 1 widget, and you simply reveal or hide it. As needed. Hope this helps.

Do you have any examples? Or documentation?

So the intro of my game has a mini tutorial where I have a widget pop-up with instructions, then “hide” itself, then come back 3 or 4 times until the instructions are over. Here are some screen shots. Each time the HUD returns it has different text. In between pop-ups the HUD is hidden as shown in the second image.