Replicating generated levels

I’m after some advice\strategies on how to replicate a randomly generated level in a multiplayer game. At this stage the level will most likely be generated by placing static meshes the clients have rather than generated geometry.

Two approaches I can see:

Replicating an array.
https://docs.unrealengine.com/latest/INT/Programming/Gameplay/Framework/Networking/Replication/Implementation/DynamicArrays/index.html

UDP socket transfer. (Will need to implement a reliable transfer if UE4 doesn’t support it).

Does anyone have any better ideas? I’m all ears :slight_smile:

Cheers!
Bino

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,**
 };

```

Thanks Rama! I’ll go down this path first, seems nice and easy.