Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Unity Multiplayer [PHOTON]Check my current lobby

Discussion in 'Multiplayer' started by Moddwyn, Apr 6, 2017.

  1. Moddwyn

    Moddwyn

    Joined:
    Jan 27, 2016
    Posts:
    49
    So I joined a lobby called "Game". When I try to do an if statement to check if my lobby is "Game" using PhotonNetwork.lobby, it returns false. When I debug PhotonNetwork.lobby.ToString(), it debugs 'Game'[DEFAULT]. So how do I check if my lobby is "Game"?
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,990
    When you compare .lobby to "Game", what happens is that lobby.ToString() gets called and that gives you "'Game'[DEFAULT]". This is the name of the lobby and the type of it (in square brackets).
    You want to compare lobby.name to "Game".
     
  3. Moddwyn

    Moddwyn

    Joined:
    Jan 27, 2016
    Posts:
    49
    So I check if (PhotonNetwork.lobby.Name == "Game") and if it returns true, it will call PhotonNetwork.JoinRandomRoom I also debugged "joined game" when it returns true. The thing is, when i switch to Game lobby, it does debug "joined game", but it doesnt join a random room. I put a OnPhotonJoinRandomFailed but it doesnt get called. I also put a OnJoinedRoom but it also doesnt get called. What's happening?
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,990
    Moddwyn likes this.