Exposing multi-cast delegates to Blueprint
Multi-cast delegates are a great way to broadcast an event to multiple objects who listen or subscribe to the event in question. They are particularly invaluable if you have a C++ module that generates events that potentially arbitrary Actors might want to be notified about. This recipe shows you how to create a multi-cast delegate in C++ that can notify a group of other Actors during runtime.
How to do it…
- Create a new
StaticMeshActor
class calledKing
. Add the following to the class header:DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnKingDeathSignature, AKing*, DeadKing);
- Add a new
UFUNCTION
to the class:UFUNCTION(BlueprintCallable, Category = King) void Die();
- Add an instance of our multicast delegate ...
Get Unreal Engine 4 Scripting with C++ Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.