In my player controller, i have a reference to a widget that gets created during gameplay. The widget has an event dispatcher which, when selecting the widget reference variable, gives me the option to add as an event in my player controller. The issue I am having is that once the widget is created, the event in the player controller isn’t being called.
Player Controller creating widget with the event dispatcher event below:
Is it possible that the event will only call if the reference is not null to begin with, or is my issue something else?
And once this problem is solved, i also have a question about how to go about using these widget dispatchers in a dynamic list of child buttons to all send to a single event on the parent.
Dispatchers do not bind to reference variables. Dispatchers bind to the referred objects. A reference variable can point to any object during its lifetime but it does not mean those objects have their dispatcher calls registered, or even have Event Dispatchers to start with.
If you replace the object the reference is pointing at, you need to rebind the dispatcher (unless it was already registered, ofc)
For dynamically created objects; if this is the child:
So from what I gather, if i’m using a reference that starts empty, or creating a procedural list of child widgets, it is impossible to use the event created by pressing this button:
The editor will not let you rebind this one, it will complain like there’s no tomorrow. Can’t recall the exact message but it’s borderline threatening.
The circled call works great when you create something static at design time and need this child talk at the parent. Works great with actor components, too!
if i’m using a reference that starts empty
The reference is somewhat irrelevant here, you just need to register a call:
Here I destroy the component, create a new one, reference it and bind the dispatcher. This can be done without the reference but it’s handy to be able to access it later, ofc.