Help casting to widgets?

Hello! In my game, I have my menu system set up so that I need to perform casting to a widget from my level blueprint. The issue is that this widget that I am casting to isn’t a static instance; in other words, when the player clicks the back button, it will destroy that component. And it is not created from the level blueprint. How can I get access to this widget? What do I connect to the “object” node? I’ve tried connecting the player controller, the player pawn, and some others, to no avail.

Please help! Thanks!

You should be able to just use the output from the first time you created it, wherever that is, as your reference to its instance. You can store it as a variable and access at any time, via casting or whatever’s easiest.

Best practice would be to create it from the bp that will be interacting with it, so you can store the variable there. You can then use that variable to cast to the widget and perform whatever actions you need.

If that’s not option, when you create and store the variable, you can then cast to the bp that will be interacting with it and set a variable over there using your original variable containing the instance. Then you can handle all of your casting to/interacting with the widget from the bp that will be messing around with it.

I can’t really do that, because it can be created from many different locations. I already fixed it, but thanks anyways :slight_smile:

What I did was I used the “Get all widgets” function to get all the widgets of the class, got the last one in the array, and used that one.

How did you fix it?