BlueprintImplementableEvent not firing??

I am trying to use a BlueprintImplementableEvent function to set a StaticMeshComponent in a separate Blueprint. I have defined the function in the header file:
image

I have then implemented the function inside a Blueprint that is inheriting from the C++ class with the function:

However, when I try to call this in a function in C++, the function does not appear to have run. I don’t see the Print String node firing, and the meshes are not updated. There’s no indication that this is being run.

I am calling AddSymbolMesh in a separate function called by my custom GameModeBase class. This function first spawns a new Symbol object, and then calls AddSymbolMesh after it is created. Here is the relevant code:

One strange thing that I have noticed is that I can’t get ANY Print String nodes in Blueprints to fire if I am using my custom GameModeBase class, but if I switch to the default GameModeBase class, suddenly all of the Print Strings are firing again.

My main question - why is this BlueprintImplementableEvent function not actually being called in my GameMode class?

I have fixed the Print String mystery; in my custom GameModeBase class, I had forgotten to call Super::StartPlay() :

After I added that, now PrintStrings from Blueprints are correctly displaying:
image

So calling Super::StartPlay in your GameModeBase seems to initialize the PrintString functionality in Blueprints.

I am still not seeing my BlueprintImplementableEvent firing in my C++ code, so I am still looking into that…

I did a small test to see if I could get the function to fire. First, I called the function AddSymbolMesh in my BeginPlay function:
image

I then dragged the Blueprint into the Level and ran the level. Now I could see the function being fired! The mesh is also being set correctly, which is what I was wanting.

So BlueprintImplementableEvent is being run if I drag the Blueprint into the scene.

I am wondering if the issue is in my GameMode cpp file, I am spawning actors that are my C++ class, and not my Blueprint class. I will test that out next.

Finally got it working!

My suspicion about the C++ code spawning my C++ classes turned out to be accurate. I did not have a full understanding of how BlueprintImplementableEvent would fire. I was kind of treating my Blueprint classes as a way to store utilities functions that my C++ code would automatically call, but that is incorrect. Blueprints exist on top of my C++ code; my C++ classes do not know about the BP-implemented events.

Once I understood that, I rethought my approach. I am making a game where cards are generated dynamically, so instead of bringing my BP objects into my scene, I settled on spawning my C+±inherited BP classes in my Game Mode. The advantage of this was that there is a better separation of where certain functionality should be placed in either C++ or BP.

This tutorial by Alex Forsythe has been invaluable in helping me wrap my brain around how you can keep this separation of C++ and BP. It was painful and I felt like giving up a couple of times, but I am glad I stuck with it. Now I’ve got a better idea of how to continue on!

Here are some of the cards that are now generated with this system (it’s a Spot It clone for my kids):

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.