Hello, I’m here to help with a small multiplayer project. To sum up:
I have a line trace that triggers when an AnimNotify is activated in my anim montage.
-the line trace does damage in cast to pnj (my pnj).
problem: in rpc Run on server to multicast and also in run server to owning client, I can’t do any damage on the client side with my line trace, sometimes the trace called by the client executes on the server, I’ve corrected this now the client trace doesn’t do any damage (certainly because apply damage isn’t run on server) but how do I do this in my configuration? I’ll put the screens on for you.
Line trace and damage dealing should all be run on the server, client defacto should trigger the line trace, but never run it - it should belong to server
I’d break it up into proxy events.
On the client (autonomous) the anim_notify triggers fx and audio.
On the server (authority) it executes the trace and applies dmg.
On simulated proxies (sims) it executes fx and audio.
determining proxies… For Client Is locally controlled or (get local role == autonomous && Is Server NOT)
hello , in this configuration the line trace is done on the server side , but the client when it interacts the line trace, appears on the server player side.
That’s correct, it should only appear on the server side, the damage, and other effects should be triggered by that line trace, and then replicated to the server
On Listen Server the Hosting Client is the server. Their debug color would be purple. All other clients would be red and Sims orange.
Clients Do Not, nor Cannot Replicate data. Clients can Send data to the server via RPC’s, but they cannot send RPC’s to other clients.
Replication is always Server -> Client
Damage and or any other Gameplay altering mechanic should be strictly managed by the server.
The Server calculates and applies damage via a health deduction on the servers authoritative copy of the health value. It replicates the changes to all connected clients.
Attacking client would play local only hit fx etc and only send a single RPC to the server to have it “TRY” to attack.
The Server would first check if it can attack, if so execute the attack, then multicast to SIMS to simulate an attack.
All proxies should be running traces to reduce network footprint.
Attacking client needs them for localized hit fx…audio and visual.
Simulated proxies needs them for localized hit fx… audio and visual. If they aren’t reproducing the same hits as the server then there’s something wrong with the overall simulation. Outside of Floating Point Precision errors they should be getting roughly the same result.
Server needs them for dmg. It itself should not have to replicate anything beyond telling the hit client to play FX.
Player Health is a player state replicated value. It should be a RepNotify. The OnRep Function would update the hit clients UI.
The Apply Damage event on the server can call an event (On Owning Client) to execute the needed FX chain.