Search Unity

Question [Netcode] Disconnect Event From 0 WTF?

Discussion in 'Netcode for GameObjects' started by ProGameDevUser, Oct 25, 2022.

  1. ProGameDevUser

    ProGameDevUser

    Joined:
    Mar 17, 2018
    Posts:
    115
    Hi! I created two different scenes on NetCode, one client, another host, as a result, when creating a host, everything is OK, but when the client connects, it immediately throws it out, there are such errors in the console, what to do?
     

    Attached Files:

    • 123.png
      123.png
      File size:
      84 KB
      Views:
      222
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,970
    Use the same scene for both host and clients!
     
  3. ProGameDevUser

    ProGameDevUser

    Joined:
    Mar 17, 2018
    Posts:
    115
    And if you need different scenes? For a computer control scenario from a tablet, for example, they have a different interface and different scenes, respectively
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,970
    You cannot have different scenes in a network game. Everyone is on the same scene, and everyone loads the same additively loaded scenes.

    The solution is to hide certain content for some clients - visibility is a section in the Netcode manual.
     
  5. ProGameDevUser

    ProGameDevUser

    Joined:
    Mar 17, 2018
    Posts:
    115
    Damn, that's weird...
     
  6. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,970
    Not weird at all. It's the only way to ensure synchronicity in a network game. If you could have clients being in different scenes, they would have different game objects, different scripts running, different physics simulated.
     
  7. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    664
    You can have clients in different scenes if you have your own custom scene management. I'm curious though on how you handle the same scene on different platforms.
     
  8. ProGameDevUser

    ProGameDevUser

    Joined:
    Mar 17, 2018
    Posts:
    115
    I am happy to inform you that I managed to synchronize two completely different scenes :)))
     
  9. Moon1ightWolf

    Moon1ightWolf

    Joined:
    Mar 28, 2022
    Posts:
    2
    But how?
     
  10. Moon1ightWolf

    Moon1ightWolf

    Joined:
    Mar 28, 2022
    Posts:
    2
    I have the same problem :(
     
  11. ProGameDevUser

    ProGameDevUser

    Joined:
    Mar 17, 2018
    Posts:
    115
    The main thing is that their scene indexes in the build window match, and everything seems to be