Replication best practices

Hello, I’ve been going through the replication documentation and saw that RPCs are intended for transient and unreliable cosmetic changes and that when possible, using RepNotifies is better. I was wondering what the reason for this is, since using RPCs seems more straightforward and cleaner in a lot of situations.
What are the risks, if any of using RPCs to drive gameplay logic? Should i really go out of my way to use RepNotifies instead?

RPC’s are one offs, meaning they won’t be resent for newly joining, reconnects or those now entering netcull distance (relevance). RepNotifies are variables, that execute a function on value change. The are persistent in the sense that the replication subsystem will send you the updated value if its relevant. 100% guaranteed to get the latest value regardless of newly joining, reconnect, just now relevant.

Door state (open/close) is 1000000% better as a RepNotify than firing a multicast. You’d use the OnRep_ function to open/close the door based on the state value.

Anything cosmetics wise repnotifies are absolutely needed here. Static mesh, skeletal mesh, materials, emitters do not replicate. Meaning if the server changes a mesh component, that change will not replicate regardless if you tick replicates in the component. These changes have to be data driven, hence repnotify.

2 Likes

Player Health → RepNotify
Mortality (Alive/Dead) → RepNotify
Score → RepNotify
Weapon ammo → RepNotify

RPC’s are no cleaner than RepNotifies. Personally I find OnRep_ to be cleaner. Doesn’t hog up graph space.

RPC’s call events or functions on remote machines. All of the logic you would write in the graph for the event would be written in a function… OR you can have the function call an event if it feels cleaner to you.

1 Like

Thanks a lot, i had guessed it’s somehow related to reliability but didn’t realize your game state doesn’t automatically copy the server’s when you join so i didn’t think about those cases. Makes sense now

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.