#unreal

Known as Event Dispatchers on Blueprints side.

See also Binding to delegates

Dynamic delegate limitations

Dynamic delegates don’t support classes or structs that aren’t exposed to the Unreal Reflection System (eg. non-USTRUCT or non-UCLASS types)

Idioms for C++ delegates

Use DECLARE_DYNAMIC_MULTICAST_DELEGATE or its variants such as _OneParam or _TwoParams to declare blueprint-compatible delegate types.

For objects which send out events about updates to their internal state or such, it’s a good idea to send this as one of the parameters into the delegate. This makes it easy for the event receiver to handle events from multiple objects in the same handler without needing additional tracking for objects they care about.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FMyThingUpdated, class AMyThing*, UpdatedThing)
 
/* property definition */
UPROPERTY(BlueprintAssignable)
FMyThingUpdated OnUpdated;
 
/* broadcast */
 
OnUpdated.Broadcast(this);
 
 

Using BlueprintAssignable allows blueprints to bind events into your delegate. Non-dynamic delegates are incompatible with BP’s.

How to make delegate parameter optional for Blueprints

How to make const ref params optional in blueprint nodes

Known issues / bugs / weirdness

If you have a delegate and for some reason it ends up saved into a blueprint asset, you can manually clear them out and resave the asset. See Fix blueprint corruption.