Calling BP Events From CPP

There are a few ways to fire events in Blueprint but I am going to cover BlueprintImplementableEvent and BlueprintNativeEvent.

Updated over 4 years ago

Events in Blueprint

There are a few ways to fire events in Blueprint but I am going to cover BlueprintImplementableEvent and BlueprintNativeEvent.

BlueprintImplementableEvent

This is the simplest one and it allows you to call a Blueprint event from C++. You just need to use the BlueprintImplementableEvent in the UFUNCTION macro in the header file and that's it.

UFUNCTION(BlueprintImplementableEvent)
void MyBPEvent();

Which shows up in the blueprint like this:

File:BPEvent.png

Now you can call it like any other method in C++:

void AMyEventActor::BeginPlay()
{
    Super::BeginPlay();
    
    MyBPEvent();
    
}

BlueprintNativeEvent

This one works almost identically to BlueprintImplementableEvent except that it requires a C++ function to be implemented. The native definition needs to have \_Implementation after it but when calling it, call the header defined function. This gives you the advantage to optionally run the behavior of the native method if you add a call to the parent function.

(.h File)
UFUNCTION(BlueprintNativeEvent)
void MyNativeEvent();
    
(.cpp File)
void AMyEventActor::BeginPlay()
{
    Super::BeginPlay();
    
    MyNativeEvent();
}

void AMyEventActor::MyNativeEvent_Implementation()
{
    UE_LOG(LogTemp, Warning, TEXT("Doing some work here"));
}

File:NativeEvent.png

When it runs the output is:

File:Output.png