Calling BP Events From CPP

From UE4: Community Wiki
Jump to: navigation, search


Events in Blueprint[edit]

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


BlueprintImplementableEvent[edit]

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:

Blueprint Implementable Event

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

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


BlueprintNativeEvent[edit]

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"));
}

Blueprint Native Event


When it runs the output is:

Event Output