x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Why is my BlueprintNativeEvent not firing Event in blueprint

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.

Product Version: UE 4.18
Tags:
more ▼

asked Feb 02 '18 at 01:11 AM in C++ Programming

avatar image

Glenn Holland
8 1 5 5

avatar image jimmyt1988 Feb 02 '18 at 01:13 AM

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

avatar image Glenn Holland Feb 02 '18 at 01:21 AM

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?

avatar image jimmyt1988 Feb 02 '18 at 01:27 AM

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

avatar image Glenn Holland Feb 02 '18 at 01:30 AM

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

avatar image Baromad Feb 08 '18 at 02:40 AM

Where are you calling the function from in blueprint?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

more ▼

answered Feb 08 '18 at 12:14 PM

avatar image

Glenn Holland
8 1 5 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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

more ▼

answered Feb 04 '18 at 11:47 AM

avatar image

Scienziatogm
371 44 40 51

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question