What's the "best practice" way to do things like Kill Notifications in a multiplayer game?

Usually in multiplayer games when one player kills another all clients receive a notification of the event and display a message on the screen naming the killer, victim, what weapon was used (TF2) or perhaps how much gold was received (Dota2). Another example of a global notification might be when another player connects or disconnects.

I’m trying to wrap my head around the “best practice” way to implement these types of global notifications in UE4 multiplayer.
What server object should be invoking these events and what client object should be handling them? (in terms of best coding practice/use of framework).

Some options for kill notifications:

  1. The PlayerState could have a multicast “OnDeath(killer, weaponId)” event.
  2. The Character/Pawn being controlled could have a multicast “OnDeath(killer, weaponId)” event
  3. The GameState could have a multicast “PlayerWasKilled(killer, victim, weaponId)” event
  4. The GameMode could invoke a “OnDeath” event on all PlayerControllers (it would have to iterate through them though which seems a bit awkward).

Some thoughts:

  • A kill notification event involves two actors, the killer and victim. Though I would say the victim is the primary focus.
  • The killer isn’t always another human player. It could be an A.I. controlled pawn, environment hazard or fall damage.
  • Usually there is some additional information (weapon used, gold recieved.)

I would put it in the player pawn since it is the one keeping track of the health and knows when a player dies. (hp<=0)
From there you can easily tell everyone you just died and depending on how you set it up, also tell everyone how/who/what/when you died.

Thank you for your answer, that makes sense to me.

I ended up putting an OnDeath mutlicast event to the pawn.

I also added wanted global notification messages whenever new players connect or existing ones disconnect.

I added OnPlayerDisconnected and OnPlayerConnected multicasts to my PlayerState class that are called on the server from GameMode onPostLogin and OnLogout.

Both work exactly as desired. :slight_smile: