Search Unity

Custom Lobby Manager - Game Player Prefab disappears on switch to Play Scene

Discussion in 'Multiplayer' started by LutzKellen, Oct 31, 2016.

  1. LutzKellen

    LutzKellen

    Joined:
    Oct 3, 2016
    Posts:
    4
    Hey everyone, I'm currently working on creating a custom Lobby Manager for non-matchmaking play. It is mostly working, but upon moving a new version of the game I am switching to, the Game Player Prefab disappears as the scene loads.

    Specifically, in a previous version, the Lobby Player Prefab successfully switched control over to the Game Player Prefab. In the new version, when the scene begins to load (before most of the scene objects are fully loaded), the Game Player Prefab is spawned correctly using Start Positions. However the scene loads a bit more and the Game Player Prefab is completely removed from the scene.

    I added a Debug.Break() in my Custom Lobby Manager in order to debug the issue, however I don't understand the behavior still. The editor will pause once when the scene switches (the Game Player Prefab is there), and then upon resuming the editor, it deletes the Game Player Prefab and then Debug.Break()'s again.

    I am currently using the deprecated OnLevelWasLoaded(), which worked in previous versions.
    Code (CSharp):
    1. void OnLevelWasLoaded(int level) {
    2.         if (level == 0) {
    3.             SetupMenuSceneButtons ();
    4.             StartTimer (0.5f);
    5.             TurnOffScenePanels ();
    6.         } else {
    7.             Debug.Break ();
    8.             SetupOtherSceneButtons ();
    9.         }
    10.     }
    Any ideas?
     
  2. LutzKellen

    LutzKellen

    Joined:
    Oct 3, 2016
    Posts:
    4
    I have figured out the issue and am currently writing the solution to it. I will update this post when I am finished.
    If I use the LobbyGUI given by the flag "ShowLobbyGUI" and I click ready, rather than using my ready button, it will work fine.

    So clearly, I must be overriding the function poorly.

    EDIT:
    Actually, I am not overriding it at all. The issue is that when I clicked the button I was using the function of LobbyPlayer: SendReadyToBeginMessage();
    Which automatically calls LobbyManager.CheckReadyToBegin();

    Somehow I forgot to remove that.
     
    Last edited: Nov 2, 2016