[Netcode] Disconnect Event From 0 WTF?

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?

Use the same scene for both host and clients!

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

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.

Damn, that’s weird…

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.

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.

I am happy to inform you that I managed to synchronize two completely different scenes :)))

But how?

I have the same problem :frowning:

The main thing is that their scene indexes in the build window match, and everything seems to be

I have same scene and run with multiplayer play mode but this error appears and player never spawned in client side! WHY? HOW?

If you want to have platform specific scenes that contains things like world geometry specific to the platform, then I would suggest you use a “man in the middle” approach for handling scene loading. Basically, the scene would contain the platform agnostic stuff (i.e. Netcode objects, possibly camera(s), etc) and then a GameObject with a custom component (MonoBehaviour), let’s call it “PlatformSceneHandler”, that upon being instantiated and “Started” (Start method is invoked) it determines the platform and additively loads the scene(s) with the platform specific assets. Upon that scene being unloaded, you can have the PlatformSceneHandler also unload the platform specific additively loaded scene(s).

You should try to avoid having netcode assets in a platform specific scene (if possible) in order to avoid scene synchronization issues.

High Level Example:

  • Scene-Leve1-Generic

  • Server loads and synchronizes clients to this scene.

  • Contains a GameObject with the PlatformSceneHandler component that has a reference to the platform specific scene(s) to load additively for this specific level (or the like).

  • Contains platform agnostic GameObjects and any in-scene placed NetworkObjects to assure these get synchronized properly.

  • Scene-Level1-

  • Server and clients load (additively) and unload this scene locally (using the Unity SceneManager) based on when Scene-Leve1-Generic is loaded and unloaded.

  • Contains platform specific world geometry/assets.

This way you don’t need to track unique scenes per platform and try to keep them named the same thing and in the same indices position.