Ya I tried doing what I captioned below but not sure what the object reference would be. It can’t be “Player Controller” because the widgets don’t inherit from that so not sure what should go there.
casting is only neccessary and even only possible when trying to convert from an base object to a child object. This is not the case here.
It is also not enough to have a variable of Type MainMenu, you also need to initialize it with the actual object reference.
If there is only one instance of MainMenu you can use the GetAllWdgetsOfClass node and access the first entry. Similar to this, but select MainMenu from drop down instead of UserWidget, then use the result of the GET node as target input for SetMapSetting and SetDifficultySetting
I tried the below. I believe that is what you were talking about but might have mixed something up. It compiles but when I select “play” (which looks at the map variable) the game crashes with the below 4 errors since the map variable was empty and didn’t get set by the blueprint process below.
Do I have to provide a index location here and if so how can I get the right location? I just started using UE 4 and haven’t used these functions before so still learning.
Error Blueprint Runtime Error: Accessed None trying to read property CallFunc_Array_Get_Item from function: ‘ExecuteUbergraph_WidgetA’ from node: Set MapSetting in graph: EventGraph in object: WidgetA with description: Accessed None trying to read property CallFunc_Array_Get_Item
Error Blueprint Runtime Error: Attempted to assign to None from function: ‘ExecuteUbergraph_WidgetA’ from node: Set MapSetting in graph: EventGraph in object: WidgetA with description: Attempted to assign to None
It fails because your MainMenu does not yet exist when calling GetAllWidgetsOfClass. You must ensure the order of execution somehow. It depends on your architecture which way is best.
Maybe create the MainMenu Widget from Blueprint A
Maybe do it the other way around: Inside of MainMenu get the reference to Blueprint A