NetworkManager tries to sync dynamically created scene
See original GitHub issueHello everyone !
I’m just starting to try and implement netcode for my tiny simple game and I’m encountering an issue with a dynamically created scene in the active one (used to make physics predictions).
When a script dynamically creates a scene alongside the active one, the NetworkManager will try to sync it on the server side when a new client connects.
Here is an example with a script attached to an empty object on my active scene (the one that fires when the server is started) :
void Start()
{
Physics2D.simulationMode = SimulationMode2D.Script;
currentScene = SceneManager.GetActiveScene();
currentPhysicsScene = currentScene.GetPhysicsScene2D();
CreateSceneParameters parameters = new CreateSceneParameters(LocalPhysicsMode.Physics2D);
predictionScene = SceneManager.CreateScene("Prediction", parameters);
predictionPhysicsScene = predictionScene.GetPhysicsScene2D();
copyAllObstacles();
}
I don’t know how I can not sync this scene with the current lib.
One easy fix could be to check the path length in \Runtime\SceneManagement\NetworkSceneManager.cs
line 1550 like this:
if (scene.path.Length == 0 || ExcludeSceneFromSychronization != null && !ExcludeSceneFromSychronization(scene))
{
continue;
}
I assume that the default behavior would be not wanting to sync the dynamically created scenes.
Issue Analytics
- State:
- Created 8 months ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Yep, that works ! Fortunately I only have one dummy scene so that workaround works like a charm, thanks !
Glad to hear it! 👍 I went ahead and added a small section in the
NetworkSceneManager
documentation about how to do this and will go ahead and close this issue out.