Search Unity

Third Party Mirror & Syncing Complex Data Objects

Discussion in 'Multiplayer' started by Denin, May 10, 2022.

  1. Denin

    Denin

    Joined:
    Mar 5, 2015
    Posts:
    27
    Hello, I'm new to Mirror and trying to figure out architecture for complex data and I can only find examples of simple things.

    I am making a turn-based strategy game with dozens of interrelated data classes and lists of objects. The server does all of the data processing, but how do I sync the data back to the clients?

    Do I make all my data classes a NetworkBehaviour and spawn game objects in the scene as I need them and use SyncVars and hooks to maintain links between objects? Or do I use commands and RPCs to communicate data changes and have potentially hundreds of functions for updating each data field? Would I be using Messages for this? Is there something else I'm missing?
     
  2. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    RPCs are not a good idea, you will be sending constantly calling a lot of functions, which will cause a lot of lag and fps drops.
    SyncVar, in the other side, looks better.
     
    Denin likes this.
  3. Denin

    Denin

    Joined:
    Mar 5, 2015
    Posts:
    27
    Thank you, I appreciate the reply and the recommendation against RPCs. The problem I'm having is my data is too complex for SyncVars.

    For example, I have a list of characters that have statistics and each character has a list of items. Both item and character classes have numerous pieces of data that can be modified as the game progresses. So, a SyncVar won't handle the list of characters, nor will it handle the list of items within each character.

    I looked at using SyncList with a struct, but my data changes too much to use structs.

    Any other ideas?
     
  4. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    You could try with a database like Google Firebase. The idea will be that the clients update their data to the database when it changes, and then the other clients will take the data from the database when they need it.