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

You didn’t get it.

Now that I call for the OnPlayerDead event, how do I implement the blueprint code for that event?

I want the event to call the Widget ChangeText function and pass it a string. How?

Hmm, as for the multiplayer networking part, I’d defer to someone who has more experience doing that. However, I think you can achieve this by wrapping your broadcast call in a multicast function, which would then be executed on the server and broadcast to the clients. Again, though, I have no experience doing that.

Do you mean how do you actually update the text? I see what you mean. From your screenshot you have no text field variable. In the designer, click the checkbox by the field name in the details panel that says Is Variable. You’ll be able to call SetText in the graph from it at that point.

I’m lost.

This damned site does not contain enough documentation for C++, only for Blueprints.

Yes but how do I make the BP and the Event communicate?

The event receives the player, now how to pass its name to the ChangeText function?

Get a reference to your game mode, cast it to your subclassed version, and then drag off a Bind Event to OnPlayerDead… wire that up to a custom event and it will create one with the correct parameters and you can call your Change Text function from there. This thread shows some good examples.

Hey I made the BP in this way:

But the message doesn’t get printed out

Hook your ChangeText execution node into your GetPlayerDead output execution node, not where it is currently. Right now, your code reads as ‘bind to event’ and then ‘set text’. On event, it does nothing.

Ok done!

I’m glad to see that now the string gets finally printed out.

But this happens only the first time. After, If I kill the player (which already has 0 health) the string doesn’t show.

Why?

Is it possible that the cause damage functions ignores dead players and therefore will not fire the death event again?

If you see in the Debug texts, there’s the black one who says “You Killed FirstPersonCharacter_C_2”

So the function ignores nothing.

What I guess is that the event OnPlayerKilled gets executed only once. Why?

You can call events as many times as you like, there’s no limit. So there’s likely an issue somewhere else in the chain of code leading up to broadcasting the event.

This is the piece of code

I can assure you, the event gets called. I tried placing a Breakpoint in the event inside the Blueprint and… it gets called but the message doesn’t appear.

I think it’s a problem inside the Widget blueprint itself… Help <.<

Must be something in how you do your hud show and delay. I usually just make an animation that changes the opacity from 0 to 1 to 0 again and set play on that when an event triggers.