How to call a Blueprint Custom Event from C++ code?

Are “Get Last Player Killed” and the player death event both handled in C++?

If yes, what’s optimal is to have a C++ base class for the HUD. It’s not (all that) complicated - Create a simple C++ class inheriting from UUserWidget and create a UFUNCTION returning FText (you will later bind your variable GetPlayerKilledMessage to this function from the blueprint).

Then reparent your current UMG blueprint to extend from that C++ class (from the class settings panel). This way you can manipulate the text message from within C++ itself. The only other step you’ll need is to create the widget from C++ instead of BP by calling the following:



//Call this from your C++ player controller class when the  game begins:
YourBaseHUD = CreateWidget<UYourBaseHUD>(this, YourBlueprintHUDClass);
if (!YourBaseHUD->GetIsVisible())
      YourBaseHUD->AddToViewport();


In that code snippet, YourBlueprintHUDClass needs to be your actual HUD blueprint so to pass it to C++ create a public variable of TSubclassOf<UUserWidget>in your player controller and from the Unreal Editor you can point that variable to you blueprint HUD (for this method to work your player controller also needs to have a C++ base class and a blueprint subclass from which you’ll set the YourBlueprintHUDClass variable).

Another option is to wrap your Show/Hide timer in a “Do Once” blueprint node. But you’ll still need a way to reset the “Do Once” node the second time the message needs to appear so if you really want to avoid the C++ HUD you’ll have to check for a boolean in Event Tick that will tell you when to process the show message logic and that boolean needs to be set in a class that is easily accessible to your HUD blueprint - you can use the player controller or the player character class for this. Both should be readily accessible from the HUD (via GetPlayerCharacter/GetPlayerController nodes) and with an appropriate cast you’ll have your controller/character’s instance.

But like the answer hub commenter told you - I wouldn’t use event tick for this. You should propagate your event to the HUD class instead of spending every single tick checking for a text variable or a boolean.