I have an event dispatcher calling out.
But it only receives the call if I manually bind a custom event to it.
Should the call not also be received if I click the event in the details panel?
It should but think about when you set the variable value and when you âautobindâ the event - about the order of operations specifically. And the fact that dispatchers bind to instances, not to variables.
Since the ControllerEOS sits under vars category, I assume you must somehow assign the value dynamically, right? If you use the details panel first, you bind a dispatcher to a null variable and it will not work. You must do it dynamically with bind / assign.
This:
will work only if the component is a part of the actor already. This will not work:
As in:
This will not work until each instance actually expresses a desire to register.
Good point.
The BP_ControllerEOS is spawned by the player controller, and stored in a variable.
The menu is only opened when I press a button, so both PlayerController and HUD class are initialized.
When it then passes the variable ControllerEOS, it seems to be valid, and pointing to an existing instance?
Sure thing. But has this instance registered? It hasnât.
If I do this to a variable:
I will register a null instance. If the variable later on points to another instance, that instance will need to bind. For this to work, it must be explicit.
I think I understand what you mean, so when the auto-bind binds the event to the variable âControllerEOSâ (which I assume happens before âEvent Constructâ), the value of âControllerEOSâ is still null.
Then the variable âControllerEOSâ get its value from the âExposeOnSpawnâ pin, and now has a valid reference.
So by the time the âEvent Constructâ is binding the event, the variable âControllerEOSâ has a valid reference.
Am I seeing that correct?
Not sure if helpful or applicable, but the best thing about dispatcher binding is that no hard references are actually necessary:
You can do this â execute something in the widget (dispatch) and receive a call in the PC. And those two entities donât event know about one anotherâs existence. No variables needed. But the signatures must match.
For exmaple, imagine we need the PC to know when the player is operating the UI and we have 100s of buttons to bind. You could:
Every button instance will automagically register with the Player Controller.
Precisely. If you want to dispatch, you must have an instance first.
which I assume happens before âEvent Constructâ
Yup:
Thanks to your explanation of the execution order I now understand why the auto-bind failed.
I tried instead, binding in the âEvent On Initializedâ, and it runs into an error because the value of ControllerEOS is null, like you said.
So that also means the value received from the âExposeOnSpawnâ pin is not yet set during âEvent On Initializedâ.
That makes sense now.
For a possible solution I am however still trying to make out what you mean with âno hard references are actually necessaryâ.
I see in your example that you âBind event toâ in the âEvent On Initializedâ.
And instead of using a value that was passed on you seek out the playercontroller and ask for the value of a variable stored there (In my case ControllerEOS).
But is that not a hard reference then?
EDIT:
I tried to recreate the âCreateEventâ node you have.
But it is looking for event dispatchers from the current blueprint.
So I can not bind to events from a different blueprint?
You can do both. But again, to bind a dispatcher you need an instance. Where / what is the (widget?) instance that wishes to dispatch to the player controllerâs EOS BP?
By hard references I meant that you do not need to hard reference anything with variables.
I took some time to delve further into how events work, keeping your examples in mind.
I now understand the meaning behind your examples.
For my own code, I have settled on the âCreateEventâ node you used, and abandoned the auto-bind.
Everything works fine, and I understand what is happening.
Thank you for your help.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.