PUN Launcher: OnConnectedToMaster() called when I am trying to leave room and go back to Lobby

Options
I have been following along with the PUN2 tutorial and had just finished implementing the changes that would allow me to get back into the lobby, however whenever I click my "leave room" button I don't get back to my lobby. In the debugger I see that OnConnectedToMaster() was called, which when I click "leave room" again, I am prompted that I am already not in a room ("PhotonNetwork.CurrentRoom is null. You don't have to call LeaveRoom() when you're not in one.").

Any advice on what to look at? I've tried going through and comparing what I've got to the code given on the tutorial however there do not seem to be any (obvious) discrepancies. Any help is appreciated!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @sabotage_son,

    Thank you for choosing Photon!

    Is this from the PUN Basics Tutorial?
    Maybe you need to join a lobby manually once connected to master?
  • sabotage_son
    edited March 2019
    Options
    Yes this is from the PUN basics tutorial.

    I encounter the error right at the end of the page on 4 - Game Manager and Levels.

    How would you choose a lobby manually? I'm confused why the "leave game" button doesn't direct the player straight back to the lobby considering that the process of leave room is called when you press the button.

    I guess must be leaving the room in some way in order for be to receive the "PhotonNetwork.CurrentRoom is null. You don't have to call LeaveRoom() when you're not in one." error to be called. I just don't physically end up back into my lobby.

    Thank you for your help!!!!
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @sabotage_son,

    In the debugger I see that OnConnectedToMaster() was called, which when I click "leave room" again
    If OnConnectedToMaster() is called then you're done leaving the room. So no need to call LeaveRoom again. You need to call it once. When you leave the room, the client will disconnect from game server and connect to master server. If you want to join the lobby after leaving the room, call JoinLobby after OnConnectedToMaster.