Course contentsShow
← Unreal Engine Game Development
Lesson 203 of 8803. C++ and UObject ArchitectureFree lesson

Configuring Dynamic Multi-Cast Delegates for Blueprint Compatibility

Create robust event systems that allow designers to bind and trigger logic directly within the Unreal Engine Blueprint Editor.

In this lesson, you will learn how to create flexible event systems that allow you to bridge complex C++ logic with the intuitive visual scripting of the Unreal Engine Blueprint Editor.

Why Dynamic Multi-Cast Delegates?

Standard C++ delegates are powerful, but they aren't "visible" to the Blueprint system. If you want a designer to be able to drag a line from a node and bind their own custom logic to a C++ event, you need a Dynamic Multi-Cast Delegate.

The term "Dynamic" refers to the fact that these delegates are identified by name at runtime, allowing them to be serialized and saved within Blueprint assets.

Defining the Delegate

To make a delegate Blueprint-compatible, you must declare it using the DECLARE_DYNAMIC_MULTICAST_DELEGATE macro. You place this at the global scope (usually above your class definition in the header file).

// Define the signature: takes a float payload
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnHealthChanged, float, NewHealth);

Exposing to Blueprints

Once defined, you add this delegate as a property within your UCLASS. To make it accessible in the Blueprint Editor, you use the BlueprintAssignable specifier in the UPROPERTY macro.

UCLASS()
class AMyCharacter : public ACharacter
{
    GENERATED_BODY()

public:
    // This allows designers to see the event in the Blueprint "Event" list
    UPROPERTY(BlueprintAssignable, Category = "Events")
    FOnHealthChanged OnHealthChanged;
};

Triggering the Event

Because it is a Multi-Cast delegate, you can have multiple listeners. When an event happens—such as your character taking damage—you simply call .Broadcast() from C++.

void AMyCharacter::TakeDamage(float Amount)
{
    Health -= Amount;
    // Notify all listeners, including those bound in Blueprints!
    OnHealthChanged.Broadcast(Health);
}

By using the BlueprintAssignable specifier, the compiler automatically generates the necessary reflection data for the Unreal Editor to recognize the delegate as an event pin. Designers can now drag off your component in the Blueprint Event Graph, click "Bind Event," and execute any logic they desire whenever your C++ code broadcasts that event.

Key Takeaway: Use DECLARE_DYNAMIC_MULTICAST_DELEGATE combined with the BlueprintAssignable property to expose C++ events as bindable nodes in the Blueprint Editor.