I am trying to get a variable from a UMG widget to another using the node “Cast to”, however for some reason it always fails. Here is how the blueprint looks like:
Where have you set the var “Begin Game HUD” with a value? Because if you just said to the Engine that is the same type as BeginGameHUD then the value inside of the var is null.
When you create your “BeginGameHud” with the node called “Create widget” you should save the out pin into a var, then pass that var to the widget.
This is TODO list:
Create the widget Begin Game HUD through the “Create widget” node.
Save the result of that node into a var
Create your second widget(the blueprint) where you need to get access to the info of the first widget
Create a var into the second widget with type “Begin Game HUD”
Click on that var and check “Editable” and “Expose on spawn”
Create the widget with “Create widget” node then insert the outpin of the “Create widget” of the point 1) into the new var
I can create the script if you didn’t undestand something
In the explainmore.png i show you how the var should be (It’s the second widget, the one where you need to use the cast). Explain is where i create the 2 widgets.
PS: If you still have problems with that you can send me the project and i will take a look for you
Understood all but point 6. Why do i need to create the widget again if i only need to access it. However, even when i tried doing 6), i didn’t get any node asking for a “BeginGameHUD widget” input. Could you please shine some more light on this?
Oh i see. I didn’t know why you were creating two widgets because i was thinking that the widgets would show up on EventBeginPlay, but i forgot you need to add them to the viewport. Now if i understood everything correct is that doing that the variable created can now be used to cast. I’ll try to implement this.
Allright, it is working as intended. Knowing how to cast from widget to widget will make my project a lot easier. Many thanks for spending your time to help me and for such a useful tip Davide!