- Home /
How to get all created rooms and join any one of them in PHOTON
I am new to Photon. I am trying to develop a multiplayer Car Racing Game.
I have followed this code : Get the code here
I'm having an issue with this script, it seems that each lobby being created is a different lobby, and that the 'sessions open' list is always empty. The only alterations I made to keep the script from giving me errors is on line 110 putting this in
RoomOptions roomOptions = new RoomOptions () {isVisible = false, maxPlayers =10}; PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default);
Am I missing anything?
Answer by UDN_30011711-3d42-4608-a55a-5bf3a3109e16 · Nov 18, 2016 at 10:40 AM
@aditya Thanks for this suggestion. I have tried it but I am getting PhotonNetwork.GetRoomList().Length=0 even after creation of room.
private RoomInfo[] roomsList;
void OnGUI()
{
if (!PhotonNetwork.connected)
{
GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
PhotonNetwork.ConnectUsingSettings(Version);
}
else if (PhotonNetwork.room == null)
{
print ("not in any room");
// Create Room
if (GUI.Button (new Rect (100, 100, 250, 100), "Start Server. No game to Join now.")) {
RoomOptions roomOptions = new RoomOptions (){ IsVisible=false , MaxPlayers=10 };
PhotonNetwork.CreateRoom (roomName + Guid.NewGuid ().ToString ("N"), roomOptions, TypedLobby.Default);
print ("number of rooms = "+roomsList.Length);
}
// Join Room
if (roomsList != null)
{
for (int i = 0; i < roomsList.Length; i++)
{
if (GUI.Button(new Rect (100, 50 + (50 * i), 200, 50), "Join Game" + roomsList[i].name))
PhotonNetwork.JoinRoom(roomsList[i].name);
}
}
if(roomsList!=null)
GUI.Box(new Rect(50,50,100,20),roomsList.Length+"");
}
}
void OnReceivedRoomListUpdate()
{
roomsList = PhotonNetwork.GetRoomList();
print ("room list count = "+roomsList.Length);
}
i m not a photo user but after looking at your code the problem might be the RoomOptions in which you are declaring IsVisible to False
Your answer
Follow this Question
Related Questions
Why does Photon find a room so quick! 1 Answer
Unity networking tutorial? 6 Answers
Turn based multiplayer problem 2 Answers
Multiplayer client-detect 1 Answer
How to check for a host in a certain area in a open world game? 0 Answers