Why is my BlueprintNativeEvent not firing Event in blueprint

Try:

UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Meta = (AllowPrivateAccess = true))

Then in your blueprint, it should appear in the right click menu as an event that you can pull off from

Platform: Mac

IDE: Xcode 9.2

I have created a BlueprintNativeEvent which is being called correctly in the C++ code (tested by printing to the log) but it is never firing in the BP.

.h

UCLASS()
class MYPROJECT_API ASWHUD : public AHUD
{
	GENERATED_BODY()
	
	
public:
    
    ASWHUD();
    
    UFUNCTION(BlueprintNativeEvent, Category="CustomEvents")
    void DisplayPickupMessage();
    
protected:
    virtual void test();
    
	
};

.cpp

void ASWHUD::DisplayPickupMessage_Implementation(){
    
    test();
}

void ASWHUD::test(){
    
    UE_LOG(LogTemp, Warning, TEXT("Called Event Function"));
}

I originally tried using BlueprintImplementableEvent this also never fired. I switched to NativeEvent so I could print to the log to prove that the function was being called.

Any insight into this would be great.

Unfortunately, it still doesn’t fire.

I tried “BlueprintCallable” when I used BlueprintImplementableEvent and got nothing too.
Any other ideas?

Also, do you have a link to the docs for the Meta tags?

C++ is calling it.

void ASWCharacter::Jump()
{
    Super::Jump();
    if(Cast<ASWHUD>(UGameplayStatics::GetPlayerController(this, 0)->GetHUD())){
        ASWHUD * hud = Cast<ASWHUD>(UGameplayStatics::GetPlayerController(this, 0)->GetHUD());
        UE_LOG(LogTemp, Warning, TEXT("CallingDisplayPickupMessage"));
        hud->DisplayPickupMessage();
    }
    UE_LOG(LogTemp, Warning, TEXT("Jumping!"));
}

What’s calling the c++ code, is it blueprint that is calling it or c++ code that is calling it?

Remember if you have called the function on a blueprint to call the parent function, otherwise it won’t call the C++ Implementation!

1 Like

Where are you calling the function from in blueprint?

I found the answer after reading up more on how the engine worked. I had been making an assumption that a Blueprint created from a custom class was “of that class” rather than a child inheriting from it.

This meant that in my C++ where I had specified HudClass = ASWHud::StaticClass(); I had expected it to run the blueprint graph in what was actually a child class Blueprint. This was a massive oversight on my part.

My eventual solution was to specify the Blueprint Class was to be used as the HUDClass in my ASWGameMode.cpp

I did this using the following code:

#include "Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h"

ASWGameMode::ASWGameMode()
{

    static ConstructorHelpers::FObjectFinder<UClass> BP_ASWHUD(TEXT("/Game/Blueprints/BP_MAINHUD.BP_MAINHUD_C"));
 
    HUDClass = BP_ASWHUD.Object;
  
};

Thanks for all the help. Everyone’s input contributed to my eventual solution.