I’m developing a voxel game, and I want to replicate the terrain data which right know is represented by a struct called FHierarchicalGrid, it actually works well if I split the world into actors representing a chunk of 16x16x16, but when I try to unify all chunks of the same X,Y (as it simplifies a lot the game logic), it starts lagging. So, the question is, what would be the better approach in this case?
- Use TFastSerializerArray (would be feasible, but would probably impact performance, as right now, I’m relying on the order of the arrays)
- Don’t replicate, use RPCs
- Don’t replicate, use TCP/Websockets
- Use Push Based Replication
- Keep using many actors instead of unifying them
- Modify network settings on the engine and/or actors
- Any other approach?
The terrain data is a structure as the following:
Struct replicate the entire structure and values once. When value changes in the struct the engine will only replicate the changes, not the entire structure.
I’d look at only replicating changes to the grid vs storing the entire grid (unmodified) and updating layer → row → column → span.
Create the struct (repNotify) and leave it empty on start. Add an entry when something changes. Have the Onrep function make the changes server/client as needed.
According to your article shared, I have grasped part of the structure. Thanks.
Hi, thanks for replying. But wouldn’t I still need to send the chunk data to the clients when the players joins?
I’m also noticing that the major problem is that actors takes too long to replicate, I have 625 chunks and it takes around 5 minutes to replicate all of them, but I also have found someone having a similar problem with way less data: Initial actor replication optimization - #5 by Justin.Dooley
I reduced the number of chunks to 9, and when profiling it’s clear that it only creates one chunk per second:
Each chunk have around 24kb of data, wouldn’t that be too low to bottleneck the network?
If the replication process is expensive and you’re working with very large structs, consider parallelizing the copy operation across multiple threads or processes if your language or runtime supports it.
depends on how many other things are being replicated, number of players that need the data etc.
130 Kbp/s seems like the average I’ve seen in games with high player counts.
In my test, it only have two players and these 9 chunks I mentioned, each chunk has 16 replicated properties, but only 5 of them are populated and in fact replicated
By the profiler, it seems like it’s send around 40 kbps and don’t go much above it