Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Third Party Mirror : SyncLists and SyncVars on Player objects

Discussion in 'Multiplayer' started by bindon, Jan 26, 2022.

  1. bindon

    bindon

    Joined:
    May 25, 2017
    Posts:
    20
    I managed to get SyncLists and SyncVars to work on a regular game object, but it seems like nothing I do can make these work on Player objects (cloned from a prefab). I can see on the server the Player clone has been created and data populated. The Player object gets spawned as expected on the client, but SyncLists are empty and SyncVars are uninitialised. Any clues?
     
    Last edited: Jan 27, 2022
  2. bindon

    bindon

    Joined:
    May 25, 2017
    Posts:
    20
    I got a sort of resolution to this by reading this article:
    https://mirror-networking.gitbook.io/docs/guides/synchronization/synclists

    and noting that:
    QUOTE: "SyncList must be declared readonly and initialized in the constructor."

    Once I had readonly in place, it made me re-write some code and subsequently everything worked.
    But I don't completely understand why what I was doing before on regular Gameobjects also worked without readonly in place. (But that is a question for another time.)