Bug with locking a room

Options
Hi, I'm coding a fps game, and I have a problem with the room. When the masterClient closes the room once there are enough players, it breaks the others player's game: They unload the menu scene and load the game scene, as expected, but then they unload the game scene.
When I try without closing the room, it works fine. It seems that closing the room unloads all scene loaded after joining for the non-masterclient players.
private void StartGame()
    {
        // Lock the room
         if (PhotonNetwork.LocalPlayer.IsMasterClient)
            PhotonNetwork.CurrentRoom.IsOpen = false;


        // Unload main menu, display loading time
        SceneManager.UnloadSceneAsync(SceneManager.GetSceneByName("Main Menu"));
        StartingText.text = "Loading world...";

        // Add map 1 to loaded scene
        SceneManager.LoadScene(2, LoadSceneMode.Additive);
        Debug.Log("Load map 1 scene");
        inMatchMaking = false;
        isInGame = true;
        inMainMenu = false;
    }
Am I doing something wrong ?

Comments

  • Tobias
    Options
    Closing the room doesn't affect the scene at all.
    It will trigger a change of room properties and it will tell the server not to add new players (nobody can join anymore, no matter what).
    It's up to your logic, how scenes are loaded by default.

    Maybe some script in either scene is a problem triggering this.
  • GabRay
    GabRay
    edited May 2019
    Options
    Hi, I added some debug logs to see where exactly the problem comes from. It appears that when the master client locks a room, it makes the other players to reload their main scene, then to reload the network script attached to this scene. Is it an expected behavior ? Nowhere in my scripts I tell unity to load or unload this scene, I never touch it

    Edit: I did one more test: I displayed the instanceID of my network game object. It did changes after the room was locked, but it is not a prefab and I instantiate it nowhere in my scripts, so it seems it is the whole scene that has been reloaded, but as I said, this reload doesn't come from my scripts
  • GabRay
    Options
    up