Hi all,
I try to set a reference to an C++ defined UActorComponent (“GameplaySystemComponent”) on construction of my user widget.
Basically the GameplaySystemComponent should send a delegate broadcast when an attribute (e.g. Health) updated his value. The given user widget listens to this delegate to update his healthbar.
My issue:
The only way to get a valid reference is when I find my testing Actor (“NewBlueprint”-class) on “Event Construct” and get his GameplaySystemComponent like in the screenshot below.
Every other (preferred) way doesn’t work for me. On “BeginPlay” of my testing Actor i create the widget and set the reference which is marked as “expose on spawn” and right after, I use a “Initialize” function to set the reference manually. Inside this function the reference is valid, but right after it is invalid. Even if I delay the function it doesn’t work.
I also tried with other variable types like Text or float and every time it is the same. I’m also confused by the callstack. As I know “Event Construct” is something like “BeginPlay” for Widgets, but “Initialize” is called before “Event Construct” and even before “Event PreConstruct”.
I hope someone could tell me how to setup a reference the right way.