C++ Event dispatchers: How do we implement them?


New to UE4 c++ API.

How do I subscribe to OnTestDelegate from a different c++ actor.

Thank you,
Nihal Kenkre.

1 Like

Why did you use





DECLARE_DYNAMIC_MULTICAST_DELEGATE is very often used in the gameplay framework so I am wondering why I would use it instead of DECLARE_EVENT.


This is what worked

#include "Acpp_character.h" // to get the class declaration

void Acpp_tennisBall::BeginPlay ()
    Acpp_character *c =  Cast <Acpp_character>(GetWorld ()->GetFirstPlayerController ()->GetCharacter ());
    c->OnMoveToPosition.AddDynamic (this, &Acpp_tennisBall::MoveToPosition);

Is there a elegant way to do this via ConstructorHelpers. The Acpp_character object is instantiated only ingame through the custom GameMode’s Default Pawn Class.

Do I need to remove delegates (REmoveDynamic) when the actor is destroyed? How does that work with UE garbage collection management?

It is actually dynamic delegates. If you mark BlueprintAssignable it will appears as blueprints’ eventdispatcher

I’m having trouble binding methods from other objects. Can someone help me?

The subscription to a delegate is a weak reference, so you don’t have to worry about them keeping objects from being garbage collected.

1 Like

Can someone show how is it done? Bind a Delegate of one Actor to another? I’m trying but the game keeps crashing. Can anyone supply a functional example code? Please?

Something like this:

void AMyActor::MyFunction(AActor* AnotherActor)
   // When AnotherActor is destroyed, call this->HandleAnotherActorDestroyed()
   AnotherActor->OnDestroyed.AddDynamic(this, &AMyActor::MyHandle);

void AMyActor::HandleAnotherActorDestroyed()
   // Do something here

It’s been a while since I did this, but both from my experience using the delegates and looking at their usage in the code base the big difference between DECLARE_EVENT and DECLARE_DYNAMIC_MULTICAST_DELEGATE is that dynamic delegates can be looked up by name and therefore can be used/exposed to blueprints. I don’t think I’ve ever been able to use DECLARE_EVENT from a blueprint.

I tried something like this and it is crashing during gameplay. how to you define the delegate?


How could i do this in blueprint?

Hi !
I not sure if this is the right place to ask this question, so please guide me if it is not.

Current I am doing the “Time Attack Racer” example, I wrote the ‘checkpoint’ entirely in C++ while the other actors in blueprint (Cause I need the checkpoint to do other things for my project).But I am Stuck at the Event dispatcher, I tried the above ’ event dispatch’ method in my checkpoint and cannot bind it to ‘Tracker’ in the blueprint.
Any Help is appreciated !
Thank :wink:


Hi, fairly new UE user here.
I noticed making the delegate function private also works. Is there any reason for it to be public instead of private?


If it works with them being private, then no.
Have you tested binding the Delegate in a different BP Class then “MyPlayerController”?
Blueprint exposed UPROPERTY’s always tell me they can’t be private. So I thought protected and public is better here :x

You can add “meta = (AllowPrivateAccess = true)” to the UPROPERTY macro on a private field, which explicitly gives Blueprint permission to read and write that field. For dynamic multicast delegates I prefer to keep the field private, apply AllowPrivateAccess, and provide a public read-only accessor to the delegate for C++ code to bind to it. That way users of your code can’t accidentally overwrite the delegate with a different instance.


Very useful post here. Having just implemented a C+±declared Event Dispatcher per the above - a note, for full functionality you will want to add BlueprintCallable as well to allow your blueprint to call your event dispatcher:

> UPROPERTY(BlueprintAssignable, BlueprintCallable, Category = “Test”)
> FTestDelegate OnTestDelegate;

Wiki on Blueprint Events / C++ Delegates

Dear Community,

I have a wiki on this topic here:

How to create Blueprint Events from C++ & C++ Delegates

Level Blueprint Friendly Delegates

When you’ve made BP-friendly delegates on objects that you can place in the level, you can simply right click on the object instance in your level -> Add Event and see your new delegate! So nice!

This is an additional benefit of using DYNAMIC_MULTICAST delegates! Multi-cast implies binding multiple of various object instances to the delegate and then firing off the event to everyone from a single .Broadcast, which can include your Level Blueprint as a recipient/listener!




Thank you, You Saved my Life in Christmas. Merry Christmas!!

1 Like

This is awsome! Thank you! :slight_smile: