Communicating between character blueprint and Widget

I have a widget with 4 images (Water, Fire, Air, Earth) I have these all toggled to hidden, and I want it so the player can press ‘1’ ‘2’ ‘3’ ‘4’ to activate each mode respectively, and when active, the image appears on the UI.

I am trying to cast to my widget, and have a key press change each of these modes. Here is an image of what I have so far:

The picture shows water and fire, I am having it hide the other elements to only show the active element. My problem lies in the casting, it wants an ‘object’ input, and nothing I am trying seems to work. Yes I am a beginner at blueprints, and I am hoping this is something simple I am overlooking, and I am on the right track.


The node you are looking for is the create widget node under interface, you can use this to call straight to a widget without the cast node.

problem is, that you dont have any input into your node “Cast To MainWidget”. You can get input by finding that widget with GetAllWidgetsOfClass or you could save the reference to the widget, after you create it (promote the output of the CreateWidget class to variable). With both ways, you wont need any aditional casting to the MainWidget.

I think that it will be ideal to create widgets in your custom HUD class, save the references to your widgets in it, and in your character save reference to your custom HUD at begin play with GetHUD -> CastToMyHUD -> promote to variable.

Give this tutorial a try, you may be able to adapt it to your needs.

Thank you everyone! I figured it out, I used the create widget node in the player blueprint, and made a variable from the return, then ‘got’ the return, and I didn’t need to cast, I just plugged the variable into everything I tried plugging the ‘cast’ into.

Heres a picture in case anyone in the future needs help and stumbles across this thead: