Multiplayer -> how to check if overlapping actor isn't any of the players in multiplayer

Hi, I’m a expert in singleplayer blueprinting. Now I’m trying to make the step to multiplayer and struggling quite a bit since there’s not much good tutorials other than replication on the interwebs.

I got this specific problem, where I’m trying to check if the overlapped actor is not equal to any of the player characters in game. In singleplayer I would just do “get player character” since there’s only one player in the game.

How do I handle this in multiplayer?

As you can see I have my Sword with collision. On the server it works good. But on the client, the sword swing hits the character itself, making yourself die… So I think the “Get player character” doesn’t work in Multiplayer and needs to be any player character in the game. Because I also don’t want to be able to hit other characters so friendly fire is disabled.

What’s the proper way of handling this for multiplayer?

Thanks in advance!

Greetz, Rebel

In your blueprint you checking that the ‘other actor’ is not your local client (player index 0 is the local client player controller in multiplayer) but then, your are applying damage to exactly that character. Surely it is the actor from the overlap event that you should be applying damage to?
Other than that I think that your apply damage should be an event that runs on the server since no client has the ability to directly affect any other client. The server must run these sort of interactions and then replicate the damage amount to the suffering client.

First of all “Apply Damage” is a Server only function (noted by the Server Icon on the upper right of the Apply Damage node) so you should start by adding a “SwitchHasAuthority” macro and only use the Authority flow (server-side flow).

Next you could simply cast “OtherActor” to a Pawn and use the function from the Pawn “IsPlayerControlled”. If false then do the damage.

Thanks guys! Got it working now :slight_smile: