I do something very similar already with my multiplayer level editor
there’s nothing to it really
Just make sure your fundamental building block / wall has a blueprint, and in that blueprint, set all of the replication stuff to true. (or you could do it in code of course, you need simulated proxy and replicate movement and the like)
then, spawn the meshes on the server!
Done!
Clients will replicate all spawned static meshes automatically as simulated proxy
This even works with moving walls / moving static meshes, just make sure you set this:
bStaticMeshReplicateMovement = true;
UE4 Network Code Robustness
UE4 Network code has some new ways to determine whether actors need to be updated, and will not update them if it is unnecessary.
So having many many replicated wall actors is not an issue, as they wont all be updated all the time, and since a lot of them wont be moving they are guaranteed to not be updating a lot.
This new UE4 Network code optimization is really handy for what you want to do!
C++ Code
Here’s the C++ code for my replicating wall:
in the constructor
//Replication
SetRemoteRoleForBackwardsCompat(ROLE_SimulatedProxy);
bReplicates = true;
bReplicateMovement = true;
bStaticMeshReplicateMovement = true;
The new UE4 Net Optimization
Check this out in the Source Code
```
UENUM()
enum ENetDormancy
: {
// This actor can never go network dormant
**DORM_Never,**
// This actor can go dormant, but is not currently dormant. Game code will tell it when it go dormant
**DORM_Awake,**
// This actor wants to go fully dormant for all connections
**DORM_DormantAll,**
// This actor may want to go dormant for some connections, GetNetDormancy() will be called to find out which
**DORM_DormantPartial,**
// This actor is initially dormant for all connection if it was placed in map.
**DORM_Initial,
DORN_MAX,**
};
```