Search Unity

NetworkList not syncing values from client to server?

Discussion in 'Netcode for GameObjects' started by princeray1001, Jan 20, 2022.

  1. princeray1001

    princeray1001

    Joined:
    Oct 6, 2021
    Posts:
    3
    Hello there,

    I have a network List that is attached to a game Object with network Object on it. I can change the value on the server, but the value isn't changed on the client. Is this a known bug, or can anyone else use networkList? If so, please send me screenshots of your code. I can attach screenshots if needed, but I am literally just declaring a networkList of floats and incrementing the first part by 1, which the server sees but the client doesn't. the client has read permission, however.
     
  2. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    664
    NetworkLists are working, you'll have to share more of your project to work out where the problem is (put any code in code tags rather than screenshots).
     
  3. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    There are a bunch of bugs with them so it depends on your use case.
    e.g. don't if your using a "Seralized anything" do this:
    NetworkList<MyStruct> mylist = new NetworkList<MyStruct>(); //this will cause issues.

    Instead
    NetworkList<MyStruct> mylist;

    void Awake()
    {
    mylist = new NetworkList<int>();
    }

    If its just ints then maybe your object has not been spawned only instantiated?
     
  4. princeray1001

    princeray1001

    Joined:
    Oct 6, 2021
    Posts:
    3
    sorry for the late response; I don't know how to use code snippets. I have included screenshots, sorry again. upload_2022-1-22_0-13-31.png The Script is located in "Updated crown". I think it is being spawned across the network as I can see it on the client. In my updateCrown prefab, I have the following script. : upload_2022-1-22_0-15-2.png Declaration of the list.
    upload_2022-1-22_0-15-35.png instantiating the list. upload_2022-1-22_0-16-25.png Object has networkObject attached to it.

    Yet when I go through the list in the same script, I can see it being updated on my server, but I can't see it being updated on my client. upload_2022-1-22_0-18-14.png
    Again, really sorry for using images here.
     
  5. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    664
    If it's working on the host the problem likely outside of the code. Can you share the project or at least enough to reproduce the problem?

    Btw the code tag option is one of the icons in the bar above where you type the messages.
     

    Attached Files:

  6. princeray1001

    princeray1001

    Joined:
    Oct 6, 2021
    Posts:
    3
    I can share more of the project, but I don't know how to. If you respond and let me know I can,
     
  7. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    664
    I've not done it, but a quick google suggests Assets -> Export Package and include all your project files.