[PHOTON]Check my current lobby

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”?

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”.

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?

You don’t have to join a lobby to JoinRandomRoom. You can even define which lobby to find a room in, as there’s a parameter for the lobby to use.
Aside from that, do the PUN Basics Tutorial to get a feeling for how to get into a room, etc…

1 Like