Blueprint Delegates and Event Calls

Overview

I have a C++ event system running in the background. You bind events to the system based on a type. When events are called they are called by the type so only listeners of that type get called.

Now I’ve created a dummy class. To help with assignment in blueprints.

Function

When in a blueprint you bind to events by calling “Bind Event” as seen in the image.

It returns a dummy class inheriting UObject that binds itself to the event system based on the type you pass in.

The returned object has a DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam that is BlueprintAssignable and you assign it the blueprint. This allows you to handle each call back in a unique way.

So far so good.

Issue

As seen in the image, binding an event to the OnEventCalled works just fine.

However, if I store the reference to the object in a variable and try to access the event OnEventCalled (Event Listener) separately. It does not work.

However this works on other things like components, lights and actors. Is this simply impossible or am I doing something wrong.

When you add the event call for event listener, it created based on the default value of object, which it’s null at that time, and at BeginPlay you assign another object which not same as old one so when you call it only execute whatever bind after that, what you experience is 2 event of 2 different object, Component work because they added in constructor.

This completely makes sense!

I’m listening to an event on the null variable. Once the game starts I fill it, but the listener I created in the blueprint is still null, it’s never updated. And you can’t. But when I assign an event to the newly created object, that works just fine.

Components on the other hand, work because they are generated during the constructor phase, and thus are being assigned to valid objects.