Hello,
I’ve got an issue with network prefab synchronization with additive scenes. Here’s my workflow:
- My game start with a Scene_boot that contains my NetworkManager
- Then, a Scene_Network_Menu is loaded in Additive mode. This scene allows the user to be a host or a client. When the user is connected to network, the scene is unloaded. (I’m not using the NetworkManager.SceneManagar on that part).
- Then, a Scene_Menu is loaded using the NetworkManager.SceneManager, in Additive mode.
Thus, I’ve got Scene_boot as main scene and Scene_menu as additive (+ DontDestroyOnLoad which contains the NetworkManager)
If the host is in the Scene_Menu and spawn a NetworkPrefab while a client is here, I’ve got no issue, the NetworkPrefab is correctly spawn in the Scene_Menu on both side.
But, if the host spawn that NetworkPrefab and then the client connects after, the NetworkPrefab will be synchronized in the Scene_boot and not in the Scene_Menu.
Does someone have any idea on what I’m doing wrong in my workflow ?
I’ve tried to use VerifySceneBeforeLoading to invalidate the Scene_boot (thinking that maybe avoiding synchronization like that could do something), but it didn’t work.
Thank you,
Kevin
I’ve not messed with additive scenes so I thought I’d try replicate what you’re doing and I’m struggling to see the benefit of using additive scenes in this way. How are you setting Scene_Menu as the active scene, with SceneManager.SetActiveScene?
Hi @cerestorm , thank you for your help.
On my first tests, the active scene was Scene_boot. I’ve tried to set Scene_Menu as the active scene, but it didn’t change anything on my spawning issue (network prefab still spawned in scene_boot)
I could probably avoid using additive scenes on that case, but I wanted to understand what’s happening, specially if it happens to me again in a case scenario where I can’t avoid using additive scenes.
I ask in reference to this:
I find the spawn happens in Scene_boot as it remains the active scene after loading Scene_Menu. I can use SceneManager.SetActiveScene to switch it but that’s not synchronised and there’s no counterpart in NetworkSceneManager to do the same unless I’m missing something. Are you doing something differently to get the spawns in Scene_Menu?
Oh I see, indeed when I do the Instantiate, I specify a transform parent which is located in the Scene_Menu (sorry, I didn’t mention it earlier). That’s why the prefab is instantiated in that scene when in local, but it seems that the network synchronization doesn’t follow
Are you using NetworkObject.TrySetParent as this appears to do what you’re after, at least it does if the parent is an in-scene network object in Scene_Menu.
Hi, sorry for the delay
Thank you very much, that’s what was missing !
I’m now using TrySetParent after the Spawn and it’s correctly shared, thank you again
1 Like