Widget displayed after any blueprint actor is clicked

Hello to everyone,

I am new to Unreal engine, and programming in general. I tried to gather up information from any decent tutorial available before but could not get to my solution.
The goal is fairly simple however.

I designed a user widget, and I would like it to display whenever a box collision inside a blueprint actor is clicked with the mouse.

I managed to make it with only one blueprint actor on the level, binding in its event graph an On click event to → Create BP widget → Add to viewport.

My problem is that I will duplicate a lot of these blueprint actors, and so, I started to consider my setup as problematic. I don’t want to multiply user widget creation (or iteration, I don’t know how to name it) if I click on several collision boxes along the game.

Hence the fact that I decided to move “Create BP widget” to another blueprint (the BP_Player controller in my case) at the end of the “Event begin play”.

In this regard, I consider that only one instance of my widget has been created and I can add it viewport later on in the game.

I experimeneted with different node like “cast to widget blueprint”, or as shown below “get all Widget of class” and trying to filter out the only one I know (and need) but this fails even more. Nothing worked so far

Now I am looking for hints as how to add to viewport this widget, when I add code after the “On cllicked event(box collision)” that is inside my blueprint actors.

Any recommendation would be greatly appreciated. If anyone knows a working snippet, I’d be glad to give it a try :slight_smile:

Greetings

Good idea. Reference it:

Any actor / widget / component can then:

No need for Get All Widget of Class.