Hello guys. I know this question propably has already been answered many times, but this is my first try on multiplayer and replication and i still cant seem to get it working. In the character blueprint i set up a simple line trace that calls the apply damage node to cause damage to the hit player.
On Event AnyDamage i subtract the applied damage from the health variable. I set the health variable to replicated, but i can only damage the client from the server. if i play as a client, i can’t damage the server
You need to call Event AnyDamage only on the server. To do this you should create a new custom event that is setup to replicate run on server reliable and have that event call Event AnyDamage.
Instead of calling Event AnyDamage in your Fire input action event you will call your Run On Server event instead.
I would also run the line trace on the server (during the run on server event) to prevent exploits.
This works, thank you very much. I didnt do this at first because the apply damage node itself sais “Authority only, will only execute on server”, so i thought this would be unnecessary. Cant thank you enough
Hi , can you show me how you fixed the issue? I tried the above but I cant find a way to call the event any damage from a custom event. I’m really confused, I tried everything but nothing works. My blueprint is exactly the same as yours. thx
After the line trace instead of calling ‘Apply Damage’ directly i pass the hit results to a custom event called ‘Apply Damage’, which only runs on the server. and then this custom event calls the real ‘Apply Damage’ function and passes the hit results to it.
@, You’re a god. Couldn’t figure this out for the life of me. I knew i had to replicate damage from server to client, just didn’t exactly know how i was going to do it. This helped me out amazingly.