Heya!
New to unity’s netcode here, I’ve got a dedicated server setup with clients working with Matchmaker, and the server and clients all connect to the network okay in the “Connection” scene, and all NetworkObjects in that Connection scene spawn on the network alright (OnNetworkSpawn being called alright on all of them). Then the NetworkManager is moved into DontDestroyOnLoad and I then call
> NetworkManager.SceneManager.LoadScene("GameScene", LoadSceneMode.Single);
And the game scene loads alright for all users but any network objects in the Game scene are then not spawned and are un-networked. All other NetworkObjects that were moved over from the Connection scene are still connected alright.
This is a test NetworkObject that I have in the GameScene, that is unconnected post-load:
I’m sure I’m just missing something simple, I could work around it by just not having any in-scene NO’s in GameScene and spawning what I need dynamically but feels like I’m just missing something.
Cheers,
James Briggs
How do you determine this? They don’t run OnNetworkSpawn?
Perhaps try enabling “Active Scene Synchronization” in the NetworkObject. But I don’t think this makes any difference. I think this only relates to whether you receive scene change events.
Which it does automatically the moment a scene with the NM in it gets loaded. You are not doing anything manually here, right?
Do you perhaps follow the often repeated bad advice of destroying the NM? If you have that problem of NM duplication the proper solution is to put the NM (together with all other persistent DDOL objects) in the very first scene that loads, which then loads the current first scene (“Connection” in your case) using the NetworkManager.Singleton.SceneManager.
Thanks for the reply!
Yeah, they don’t run OnNetworkSpawn and their components aren’t greyed out like spawned NetworkObjects are, here’s a side by side of a spawned one from the Connection scene and the test NO from the Game scene:
Tried enabling Active Scene Sync just now but no luck unfortunately
Interestingly, after testing just now, I looked at server logs and on the server the OnNetworkSpawn is getting called and am getting logs from it, so it’s just on the client that it isn’t spawning correctly.
Yeah the NM is doing the moving into DDOL itself, not doing anything manually
NM isn’t getting destroyed, is definitely the one and only instance of it, and can see that the NO in the Game scene has the correct reference to it (have tried changing name of NM in runtime and can see the NM reference on the NO change to reflect this)
Cheers,
James Briggs
Have done some more experimenting and found some interesting results
Created test scene with a network manager, network object and network behaviour that can load a second test scene with another NO on it
Pressing Start Server on first unity instance, Start Client on second and then loading second scene has same issue as my game, the NO on first scene spawns correctly but the post-load NO doesn’t spawn correctly
However pressing Start Host on first unity instance, Start Client on second and then loading second scene causes both NO’s to spawn correctly, both pre and post-load.
Going to try to build dedicated server with starting as a host instead of server and seeing how that goes as a workaround but would still be interested to know why this is happening
Could you post the version of NGO that you are using? This will help troubleshoot the issue.
As a side note, it is recommended to use the most recent version of NGO as there have been some issues pertaining to this fixed in previous versions.
Depending upon what editor version you are using:
- 2022.3 (or lower): Update to NGO v1.12.0
- Unity 6.x: Update to NGO v2.2.0
1 Like
The same issue is confirmed gone when update NGO from v2.1.1 to v2.2.0
Ahh right, will update to newest version now and try removing my workarounds
Thanks for the help!
1 Like