Question by
payalzariya07 · Jan 08, 2020 at 10:12 AM ·
c#multiplayerunityeditorphotonmultiplayer-networking
Match making in Photon
Hi, I am trying to create a room and joined a player in the room using photon 2. Here is my code. //for Create Room
void CreateAndRoom()
{
float randomRoomNo = Random.Range(1.0f, 50.0f);
RoomOptions RoomOp = new RoomOptions();
string[] customProperty = {
playerroomtype
};
RoomOp.CustomRoomPropertiesForLobby = customProperty;
ExitGames.Client.Photon.Hashtable prop = new ExitGames.Client.Photon.Hashtable();
prop.Add(playerroomtype, "readytojoin"); // playerroomtype is 2 player room or 4 player room
RoomOp.CustomRoomProperties = prop;
RoomOp.IsVisible = true;
RoomOp.IsOpen = true;
RoomOp.MaxPlayers = (byte)Data.CurrentSelectedPlayer;
PhotonNetwork.CreateRoom(randomRoomNo.ToString(), RoomOp, TypedLobby.Default);
Debug.LogError("ROOM NAME " + randomRoomNo.ToString());
}
//for joined room and create new room. in this method i am calling in button clicke event
public void QuickMatchRoomes()
{
for (int i = 0; i < createRoom.Count; i++)
{
if (createRoom.CustomProperties.ContainsKey(playerroomtype) && createRoom.PlayerCount != Data.CurrentSelectedPlayer)
{
if (createRoom.CustomProperties[playerroomtype].ToString() == "readytojoin")
{
found = true;
PhotonNetwork.JoinRoom(createRoom.Name);
}
}
}
if (found == false)
{
CreateAndRoom();
[/code] WaitingPanel.SetActive(true);
}
}
Also, I am updating the room list. it works well for 2 player rooms and 4 player rooms. when a new player joined the 2 player rooms and 4 player rooms it 's not working.
Comment