Download

Applying Damage Not working in multiplayer on clients

Hi guys, I got a problem with multiplayer. I’m trying to deal damage to AI Enemies. But the damage it deals is always 0 no matter what damage numbers I pass on. From my understanding you have to run Apply Damage on server and then update the health on clients. But I don’t know how to update the health on clients. I tried some code, but the problem is that the damage that’s passed on to the Event Any Damage is always 0. How do I solve this?

Here’s my code:

Here in the Any Damage event the damage it does is always 0, so the health of the enemy doesn’t get updated to take damage

Any Help would be greatly appreciated! Thanks in advance!

BP_Sword has to be set to replicated or it can’t call rpc events. Alternatively you can set up damage logic on the player bp and interface to it (I do this because attachToActor and attachToComponent nodes are needlessly sticky on the server).

Thanks for the help! BP_Sword was not set to replicated. Unfortunately setting it to replicates still does not work :frowning: Any other ideas? Thanks

If you unhook the variable “damage” and just roll an arbitrary damage value, does that work?

Nope, that also doesn’t work. The damage is not passed to the Event Any Damage in BP_EnemyBase somehow

Ok I got it working by moving the code from BP_Sword to BP_PlayerCharacter! I detect a hit in BP_Sword, then I do Get Owner to get the BP_PlayerCharacter holding the sword. Then execute the rest of the code in PlayerCharacter

But don’t you want the character hit by the sword to take damage? not the person holding (owning) the sword ?