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

Question Should NetworkList being sync up on client connection?

Discussion in 'Netcode for GameObjects' started by Suduckgames, Oct 24, 2022.

  1. Suduckgames

    Suduckgames

    Joined:
    Nov 28, 2016
    Posts:
    218
    Hi there!

    I am using a NeworkList to sync a list of soldiers in my game.

    It works fine if both clients are connected at the same time. However, if a client enters later ( o reconnects), the NetworkList is not synced.

    To give more information,

    Steps:
    1. Client A connects and add 3 items to the list
    2. Client B connects and see Client A prefab with 0 items in the list
    3. Client A add 1 more item to the list
    4. Client B receives 4 callbacks ( the 3 old items plus the new one) that the list has changed


    Is this the expected behavior? I expected it to work like the NetworkVariable that will sync the values when a new client connects
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,019
    I believe this was a bug in 1.0.2 that got fixed in 1.1.0. Try 1.1.0 if you aren't on that version.
     
  3. lavagoatGG

    lavagoatGG

    Joined:
    Apr 16, 2022
    Posts:
    223
    in 1.1.0 it doesn't call OnValueChanged when connecting. I am using 1.0.2 and I am not having any problems with NetworkList
     
  4. Suduckgames

    Suduckgames

    Joined:
    Nov 28, 2016
    Posts:
    218
    I got the same problem on both versions, I got them in 1.0.2 and tried uploading them to 1.1.0 but the same problem persists
     
    Last edited: Oct 25, 2022
  5. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    603
    Check the network list length in OnNetworkSpawn of the containing object, if the network list is working correctly it should contain the current values.

    What you're describing sounds like a bug to me though, it might be worth creating a Github issue for it.