Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    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:
    6,596
    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:
    229
    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:
    676
    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.