Unable to join same room for Third player In photon?

Options
Here when i create a room from first person , room is created and when second person comes it joins the room, but when third person comes it creates new room ,while it should join the same room because the room have maxplayer =10.

As there is joinrandomroom() function , So , i have tested multiple times but still third person creates new room.
void Start () {
	competePlayeScale = true;
	PhotonNetwork.JoinRandomRoom();
//		PhotonNetwork.JoinOrCreateRoom ("room_", new RoomOptions{ MaxPlayers = 10 }, TypedLobby.Default);
	spawnPoint = new Vector3[] 
	{
		new Vector3 (-1.2f, -17.1f, 35.1f),
		new Vector3 (15f,-16.9f, 35.4f),
		new Vector3 (-15f,-16.9f, 35.4f),
		new Vector3 (-40, 0, 0),
		new Vector3 (-20, 0, 0),
		new Vector3 (0, 0, 0) ,
		new Vector3 (20, 0, 0),
		new Vector3 (40, 0, 0),
		new Vector3 (60, 0, 0),
		new Vector3 (80, 0, 0)
	};

}


void OnCreatedRoom() {

}

void OnPhotonRandomJoinFailed() {

PhotonNetwork.CreateRoom (null, new RoomOptions{ MaxPlayers = 10 }, null);

} void OnJoinedRoom() {

if (PhotonNetwork.playerList.Length == 1) {

MyPlayer = (GameObject)PhotonNetwork.Instantiate (prefabSamurai.name, spawnPoint[0],Quaternion.identity, 0);

MyPlayer.transform.rotation = Quaternion.Euler (0f,180f, 0f);

MyPlayer.transform.localScale = new Vector3 (15, 15, 15);

}

if (PhotonNetwork.playerList.Length == 2)

{

MyPlayer = (GameObject)PhotonNetwork.Instantiate (prefabSamurai.name, spawnPoint[1], Quaternion.identity, 0);

MyPlayer.transform.rotation = Quaternion.Euler (0f,200f, 0f);

MyPlayer.transform.localScale = new Vector3 (15, 15, 15);

}

if (PhotonNetwork.playerList.Length == 3)

{

MyPlayer = (GameObject)PhotonNetwork.Instantiate (prefabSamurai.name, spawnPoint[2], Quaternion.identity, 0);

MyPlayer.transform.rotation = Quaternion.Euler (0, 200, 0);

MyPlayer.transform.localScale = new Vector3 (15, 15, 15);

} }

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @wasifk308,

    Thank you for choosing Photon!

    Please do not bomb or spam the forum.
    One post is enough.
    Replicating posts does not increase your chance of getting answers.

    I don't see anything odd with the code that can cause what you are saying other than players being on different regions.
    Please go through the matchmaking checklist.

    I prefer this code also:
    RoomOptions roomOptions = new RoomOptions();
    roomOptions.MaxPlayers = 10;
    PhotonNetwork.CreateRoom (null, roomOptions, null);
  • wasifk308
    Options
    @JohnTube

    Thanks For the Link.It helped me alot.
  • wasifk308
    Options
    @JohnTube
    JoinRandomRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.
  • wasifk308
    Options
    Sometimes i get this error since i did not get call back OnConnectedToMaster
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    yes, you need to be connected to Master Server to be able to call JoinRandomRoom operation.

    Implement connection callbacks:
    OnConnectedToMaster() (if "AutoJoinLobby" is disabled/unticked/false)
    or
    OnJoinedLobby() (if "AutoJoinLobby" is enabled/ticked/true)
    Implement disconnection callbacks:
    OnFailedToConnectToPhoton(DisconnectCause cause)
    and
    OnDisconnectedFromPhoton()
    and
    OnConnectionFail(DisconnectCause cause)
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    @wasifk308
    please stop spamming or we will ban you.