Creating events that can be implemented in Blueprint

Another way that C++ can be more tightly integrated with Blueprint is the creation of functions that can have Blueprint implementations in native code. This allows for a programmer to specify an event, and invoke it, without needing to know anything about the implementation. The class can then be subclassed in Blueprint, and another member of the production team can implement a handler for the event without ever having to go near a line of C++.

How to do it…

  1. Create a new StaticMeshActor class called Spotter.
  2. Make sure the following functions are defined and overridden in the class header:
    virtual void Tick( float DeltaSeconds ) override; UFUNCTION(BlueprintImplementableEvent) void OnPlayerSpotted(APawn* ...

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.