Network:How I can make overlap events between online players?

I want to know how I can make a charakter overlap event, which is casted to an other online player.

For example…the player who has more health destroyed the player who has lower health.

Thank you all for help:)

OK. Overlap event happens to both players that overlap each other, AND these both happen on BOTH computers in a networked game, so you want to test for IsAuthority or IsServer first thing in your Overlap event handler.

Now we can’t say which player character is which very easily, but we don’t have to.
The event is firing on both, so when we measure the health of one against the other, if the one the event fired on is LESS, then we just quit the function without doing anything (leave False pin on Branch unconnected, for example).

If it is MORE than the other player’s health, then you continue and destroy that other player. See now it works and you don’t have to know who is whom, and it’s okay that the event fires on both machines for both players (that’s 4 events!) because only 2 events will go past the Server/Authority check, and only 1 of THOSE will pass the Health check.

You might be able to store the health on something other than a replicated variable on a PlayerState, but in network games you will have a lot better progress in developing if you put those kinds of things like Health on PlayerState than on Pawn or Controller, and replicate them. This still might work if it’s on Pawn or Controller, but I’m not sure.

Can you make a screenshot please?So it’s easier to understand.

I can’t really do a screenshot because I’m at work, away from my unreal computer at home.
Maybe I can explain more simply though by going step by step:

  1. On event BeginOverlap, first check if IsServer (it’s a built-in function that returns a boolean true or false), and put that into a Branch node, and only go to the next node on True.
  2. The beginoverlap event should have an Other actor pin, representing the Actor that just overlapped with the one that’s running the code. Pull out that pin and cast to whatever Pawn class is used by the players, then get THAT object’s Health value (which might require another reference to PlayerState and maybe another cast to your specific type of PlayerState that you use, or PlayerController, or maybe not at all, depending on where you store your Health variable for the players).
  3. Using that health value you just pulled out of the Other Player, put it in a < node on the bottom pin. Put the Health value from the actor that’s running the code into the top pin. Branch: if true that other player’s health is less than mine, kill the other player (by pulling the Other Actor pin out and putting it in a Destroy node, or a custom function, or an Apply Damage function, however you want to do that).

Done.