Event dispatcher receiving call only if I bind event manually

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?

1 Like

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:

image


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?

1 Like

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?

1 Like

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 :point_up_2: → 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.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.