How to switch Room in already playing Game?

Options
I am making a social game ,it has a private room and lobby room.
The private Room only player himself can visit it.
I am new programmer.I don't know how to switch Room in Playing Game(in already connected game)。
Need I Use PhotonNetwork.ConnectUsingSettings("2"); again to enter a new room?

Comments

  • Hi @Humor1217,

    no, you don't need to call ConnectUsingSettings(...) again. This is only necessary if you have been disconnected from Photon before. Switching the room is not possible with a single command because it requires you leaving your current room before joining a new one. So firstly you have to use PhotonNetwork.LeaveRoom() in order to leave the current room and wait for the OnLeftRoom() callback. This callbacks informs the client, that he actually left the room. After receiving this callback you can use PhotonNetwork.JoinOrCreateRoom(...) (or another function which does the same) in order to join another room.

    Hint: if the private room can only be visited by one client, you can think about making this part available only when not being connected to Photon, in other words: when being offline.