Dealing damage multiplayer( 2 playable chars)

Hi!

I’m making a online sword fighting game with 2 players in an arena. I’ve been having a lot of trouble getting the apply damage to work for both characters. When I test in separate viewports the server side player can deal damage and kill the client, but when the client deals damage and should be killing the enemy, he dies himself! Any thoughts on why this is happening?

Regards, Samuel

I have made an online 1v1 sword fighting game too! here it is if you want to check the trailer out GD41 Blood and Steel Trailer - YouTube

It depends on how you coded your apply damage, maybe for some weird reason you are applying damage to the wrong player, if you can show some of your code for this I could help you better.

Hey thanks for your reply. Checked out the trailer, cool stuff!

i’m applying the damage from the attached weapon and then using get any damage inside my 0_base character blueprint (which is a parent class for all players). I have my characters defined with an index, which i’m trying to use for player reference. Is this a similar method to what you have done?

posting some blueprints soon…
-SamuelB

the 2nd pic is basicly how i’m trying to get the death defined and replicated.Tried lots of things with this…Oh, that 2nd pic is also missing my boolean, activate death, but that didn’t work either on my other attempts.

the last pic is how i’m calling the functions on event tick

Hi any chance you could help regarding this issue?

-Samuelb

You also have your apply damage having a correct reference to the damaged actor, and the apply damage should be called on the server rather than the client. (Custom even, run on server).

Your receive damage should function properly.

Keep in mind that most logic should run on the server because it has authority over the clients, if a client is setting itself as a player ID then no one else in the game will know about it.

Hey there thanks for the reply, hmm i wonder if i’m setting my character ids incorrectly in that case. I’m setting player 1 and player 2 in the 0_base char bp, on event beginplay. Do you mean i should be making a custom event that executes on server to set the ids correctly?

-SamuelB