Skip to main content

Add Observer (Function)

UFUNCTION(
BlueprintCallable,
Meta = (DisplayName = "Add Observer (Function)", DefaultToSelf = "Observer", AutoCreateRefTerm = "EventClass"),
Category = "Event System")
FLES_ObserverHandle BP_AddObserver_Function(
UPARAM(Meta = (AllowAbstract = "false")) const TSubclassOf<ULES_Event>& EventClass, UObject* Observer,
const FName FunctionName, const FName Channel = NAME_None);
Parameters
EventClassThe static class of the events the Observer should listen for.
ObserverThe object that will be notified when events of EventClass type are sent on the Channel.
FunctionNameThe name of the event handler function that will be called when the event is received. This function should take 1 parameter of the type of your event and return no values.
ChannelDetermines the channel the event will be sent on. Observers are notified only about the events sent on the channel they're listening on.
ReturnA handle to the newly created observer record in the Event System. You may use this handle later to remove this particular observer record from the Event System. If FunctionName is not the name of a blueprint-callable member function of the Observer, an invalid handle is returned.

Adds the Observer to the Event System and marks it as listening for events of EventClass type, that are sent on the specified Channel. The event handler will not be called if an Event is sent and the Observer has already been garbage-collected.

Example usage:

The Observer must have a member function with name FunctionName that takes 1 parameter of EventClass type and returns no values. Below is an example of an implementation of such a function in Blueprint: