In a networked game, I’m trying to understand what I need to replicate, i.e. what to flag as “Replicated”.
Let us say I have:
class ANanoFactory : public AActor
These factories are placed around the map producing stuff as per AI instructions and can be destroyed by players.
If I set
bReplicates = true
in the constructor it will replicate the actor to remote machines. Does that mean the server will take charge of the actor and replicate to clients, and if
bReplicates = false
then what happens? Does it mean that factories placed in the Unreal editor only exist on the server and are not rendered on clients and if a player triggers an event that spawns a factory actor then that factory only exists for that player? Despite reading lots of articles, posts and wikis on replication I still struggle to wrap my head around this.
Presumably I need only set the “Replicated” UPROPERTY for variables that need to be handled on a client. So for
it might make sense to set this to UPROPERTY(Replicated) if there is a visible damage bar, but if not then can I just not replicate it and the server will handle Health? Presumably if Health reaches zero then the server can issue a notification to clients to apply the explosion effect using a NetMulticast RPC (Remote Procedure Call), and if the server updates the mesh from a working factory to a destroyed factory that will be updated on all clients?
How UE4 does networked games is really cool, but clearly I need some pointers on how to use it correctly. Looking at the Shooter example just confuses me further as for example RunningSpeedModifier and BaseTurnRate are not replicated, but CurrentWeapon and bIsTargeting is replicated and I don’t get (yet) how this is determined.