#Procedural generation in Multiplayer

1 messages · Page 1 of 1 (latest)

eager zinc
#

Hello,

I'm trying to make a game that procedurally generates the world. My current set up creates the entire world in the server world and then divides the world into many chunks (32x32 tiles). I tried creating a chunk ghost entity that stores a buffer of all the tiles for that chunk, but it failed because ghost entitites couldn't store that much data. So I retried it with RPC, but I'm having trouble getting the BlobAsset containing the tile data for a chunk from the client world.

What is the standard practice for using world chunking in Netcode for Entities?

dense summit
#

Generating the world on the server side and synching it over the network sounds like a huge bandwidth cost.
I would most likely have the procedural generation system on both client and server and just sync the seed of the world.

dense lichen
# eager zinc Hello, I'm trying to make a game that procedurally generates the world. My curr...

Hi! I had the same issue with my voxel game. Procedural generation on both sides would be one way to solve it if your game doesnt have player modified worlds. I solved the issue by incorporating a dual channel connection with a TcpClient and TcpServer. All of my player actions utilize ghost synchronization and RPCs for sending information about placing and breaking blocks, but loading of new chunks is done by sending compressed voxel data (I am using only Run Length Encoding for now but will probably add on something like LZ4 compression to further clean up any more patterns that could be compressed) over a TCP connection. This is a bit finnicky to get working with DOTS because it can be difficult to get the data over to your systems. I use a static ConcurrentQueue to deliver the information to my systems, where it is then uncompressed and added to my voxel data singleton.

eager zinc
# dense lichen Hi! I had the same issue with my voxel game. Procedural generation on both sides...

Oh wow this is quite a bit of stuff outside the basic tutorial on dots docs haha. I did end up implementing a seed based world generation so the worlds are being built on both client and server worlds separately. But im pretty lost on how to sync the changes being made to the world. How are the changes maintained when a new player joins ur game? RPC’s won’t be there when they join long after the change. And it’s probably not the best move to have each voxel be a ghost

dense lichen
# eager zinc Oh wow this is quite a bit of stuff outside the basic tutorial on dots docs haha...

Haha yeah, netcode for entities seems great when youre working with small bits of data that need to be synced, and theres not many situations I can think of where you would need to send this much information to clients all at once. A voxel game seems to be a pretty unique case because worlds can be completely player built which can add up to needing to send a lot of information that can kinda be un-pre-determinable. When a new player joins the game, they just get sent the chunk data that is stored on the server. Its always up to date because any changes a player makes to their world is synchronized through an RPC. RPCs are only used to send that small amount of data that changes, which is then updated on the server, and sent to other clients to update their simulation as well

#

Just to clarify, the tcp request for data is only made for loading new chunks. From then on, everything is dealt with through rpcs.

#

If youre going for a similar type of game and are thinking about doing the same thing, heres the .net docs on tcpclient and tcplistener. Let me know if you need any more help figuring things out!
https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.tcpclient?view=net-9.0
https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.tcplistener?view=net-9.0

Provides client connections for TCP network services.

Listens for connections from TCP network clients.

eager zinc
#

Wow thank you so much for the detailed feedback. I think I have a decent idea of how ur set up works. I’ll take a look at those links and give it a try and get back to u