Creating a multicast delegate

The standard delegates used so far in this chapter are essentially a function pointer—they allow you to call one particular function on one particular object instance. Multicast delegates are a collection of function pointers, each potentially on different objects, that will all be invoked when the delegate is broadcast.

Getting ready

This recipe assumes you have followed the initial recipe in the chapter, as it shows you how to create TriggerVolume that is used to broadcast the multicast delegate.

How to do it...

  1. Add a new delegate declaration to the GameMode header:
    DECLARE_MULTICAST_DELEGATE(FMulticastDelegateSignature)
  2. Create a new Actor class called MulticastDelegateListener. Add the following to the declaration: ...

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.