NetworkLobbyManager don't call OnLobbyServerSceneChanged

Hello,

I’m somewhat new to Unity so please expect potentially dumb questions.

(Hmm, space, space, return doesn’t seem to create an empty line …)

I started creating a networked game using the old NetworkManager. After learning that there is the newer NetworkLobbyManager i switched to this class, expecting that it will speed up the lobby creation process. Stupid me 8).

The newest issue is, that i can’t create the battlefield when the game switches to the play scene.

In ‘OnLobbyServerPlayersReady’ i create the structure of the battlefield and than, i thought, ‘OnLobbyServerSceneChanged’ would be an excellent place to create all the game objects. Obviously i was wrong (otherwise i wouldn’t bother you with this problem 8). ‘OnLobbyServerSceneChanged’ is never called.

The two methods look like this:

    public override void OnLobbyServerPlayersReady()
    {
        I_nbBFManager.CreateBattlefieldStructure(true);
        base.OnLobbyServerPlayersReady();
    }

    public override void OnLobbyServerSceneChanged(string _strSceneName)
    {
        if (!_strSceneName.Equals("Configuration"))
            I_nbBFManager.SpawnBattlefield();

        base.OnLobbyServerSceneChanged(_strSceneName);
    }

Executing the ‘base call’ first doesn’t change anything.

There is another problem. Maybe the two are connected. The game object with the battlefield manager stays inactive after the scene change as long as there is also a network identity on it. Nope, no sub object with another network identity in the tree.

It looks like there is an exception while the lobby manager loads the play scene. So all that should happen after the exception never occurs. But i can’t see any appropriate exception message and i have no idea what to do to find the problem.
I have searched the forums but this issue seems to be exclusively mine. Any help would be appreciated.

Thanks
Ralf Biniasch

Hello,
maybe this will help someone else.
It was a timing problem. I did some initialization (connecting to faction) in ‘OnStartLocalPlayer’ on the player object. But this method is called before ‘OnLobbyServerSceneChanged’. Hence the battlefield and the factions weren’t created. So i had to restructure the battlefield creation process.

The sequence is:

  1. OnLobbyServerPlayersReady (lobby scene)
  2. OnStartLocalPlayer (play scene)
  3. OnLobbyServerSceneChanged (play scene)

This leads to another problem. If you (like me) create a dynamic scene at runtime the player objects will be instantiated before the spawn points are created. Even if you instantiate the spawn points in the lobby scene and set the ‘DontDestroyOnLoad’ flag on them, the players will be created before the spawn points are activated and all spawn at position (0,0,0).
I circumvented this by manually setting the position of the player object in ‘OnStartLocalPlayer’. Thus i have no need for spawn points at all.

This may not be the best practice but it works for me. If there are better solutions i would be glad to get some info about them.

Thanks
Ralf Biniasch

Hey Ralf,

When I try to use OnLobbyServerSceneChanged, I’m told that no suitable method is found to override. What do you have to add to a script to access this method?