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++.
Create a new
StaticMeshActor
class calledSpotter
.Make sure the following functions are defined and overridden in the class header:
virtual void Tick( float DeltaSeconds ) override; UFUNCTION(BlueprintImplementableEvent) void OnPlayerSpotted(APawn* Player);
Add this code to the constructor:
PrimaryActorTick.bCanEverTick = true; auto MeshAsset = ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT("StaticMesh'/Engine/BasicShapes/Cone.Cone'")); if (MeshAsset.Object != nullptr) { GetStaticMeshComponent...