A. Using a rep notify to update health, which then runs an update widget event to display current health
vs
B. Using an RPC to do the same
vs.
C. Simply replicating the health property, and running a tick function client-side to update the player health every second
It seems to me if I want to reduce network traffic option C would be best? Or is using a tick-function high cost on the processor even for something as simple as that. Apologies as I am very new. Cheers.
repnotify is the most efficient as its event driven.
Repnotify updates when relevant - ie if a player joins late it still works
RPCs only fire once so if a player joins late it wont work. RPCs can also fail.
Replicated is fine but wont call the event hence you need the tick which is wasteful
Thanks for your reply. Am I correct in thinking RepNotify is usually the answer then to Server to Client comms? For something like Health where you need to call updates to a widget, or death when it hits 0 it seems like RepNotify is the answer, same with movement and ammo where the change is immediately relevant?
Are there any situations where Replicated is better and then you run a tick every say 10 seconds or so? I’m having trouble imagining what kind of variable in a shooter game would just be say, replicated and not RepNotify. It seems like anything relevant right away should be a RepNotify, or maybe even RPC.
Although I’ve read RPC should only be used when the order of events is relevant. So would a player damage event best be a RPC from client to the server and then a RepNotify from server back to the clients?
Sorry for the simple questions still trying to get my head around it. Appreciate you taking the time.
Use repnotify when you need to be notified, ie health changes on a UI
you can use replicated when changes dont need to be shown, ie maybe movement speed.
damage should always be done on server but you could RPC back say a damage number popup. this is better than a repnotify because its a one shot, ie if a client joins late they dont need to see previous damage.
and of course you need client to server RPC for player input, so the player can input a fire command and the server runs the damage event if valid