Search Unity

Good ways to sync procedurally generated tilemaps?

Discussion in 'Multiplayer' started by validname1, Mar 5, 2018.

  1. validname1

    validname1

    Joined:
    Feb 1, 2018
    Posts:
    26
    So I'm creating a game where there's a grid of 1024 x 1024 tiles that are randomly generated using Unity's tile map feature.

    What's a good way to send the generated tile map to players?

    I've considered sending the seed but what if a tile is changed on the server? How would a newly connected client be aware of the change with the seed alone?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Is changing tiles on the server something that will be common?

    If a rather small portion of your tiles change on the server, I'd track on the server what tiles are changed from default, and write a serializer to send all changes as a message to connecting clients. So then the server sends a seed and then the updated tiles.

    Brute force sending a million tiles to a connecting client would likely be problematic (if using UNet you're far beyond the max message length, so would have to write your own fragmentation system for this data, and I don't believe built in synclist features will support that many items).
     
  3. validname1

    validname1

    Joined:
    Feb 1, 2018
    Posts:
    26
    Unfortunately I expect the tiles to be changing, sort of like Minecraft/Terraria. I suppose this means that sending just the seed will not do.

    Would using a proximity checker solve the issue of "Brute force sending a million tiles"? Or is my understanding of it not correct?
     
  4. Driiade

    Driiade

    Joined:
    Nov 21, 2017
    Posts:
    80
    Send the seed.
    For each new client only send the difference.

    Make a proximity checker. So you only send what is view by the client.

    Only send new information. For each client, server have to know what the client is aware and not.

    Pack information. If a tile is destroyed don t send a bool for each tile. Compress the information using a maximum of bit. 1 bit = 1 tile destroyed for example.

    If you want to make it well. You jave a month or 2 front of you ^^.

    If i had to make it. I will test that.
     
    tobiass likes this.