How it works...

As with all of the other types of delegate, Events require their own special macro function. The first parameter is the class that the event will be implemented into. This will be the only class able to call Broadcast(), so make sure it is the right one. The second parameter is the type name for our new event function signature. We add an instance of this type to our class. The Unreal documentation suggests On<x> as a naming convention.

When something overlaps our TriggerVolume, we call Broadcast() on our own event instance. Inside the new class, we create a point light as a visual representation of the event being triggered.

We also create a pointer to TriggerVolume to listen to events. We mark the UPROPERTY as EditAnywhere, because this allows us to set it in the Editor rather than having to acquire the reference programmatically using GetAllActorsOfClass or something else.

Last is our event handler for when something enters the TriggerVolume. We create and initialize our point light in the constructor as usual. When the game starts, the Listener checks that our TriggerVolume reference is valid, and then binds our OnTriggerEvent function to the TriggerVolume event. Inside OnTriggerEvent, we change our light's color to green. When something enters TriggerVolume, it causes TriggerVolume to call a broadcast on its own event. Our TriggerVolEventListener then has its bound method invoked, changing our light's color.