Does anyone familiar with Unity Photon. I try to wait till all players join then start the game. I think PhotonPlayer function is no longer working.
void OnPhotonPlayerConnected(PhotonPlayer newPlayer){
if (PhotonNetwork.playerList.Length == 2) {
PhotonNetwork.LoadLevel ("StandardTrack");
}
else if (PhotonNetwork.playerList.Length == 1) {
Debug.Log ("Not Enough PLayers");
popup.SetActive (true);
}
}
tobiass
November 25, 2019, 9:12am
2
Add a Debug.Log() and write some useful info to the console. Like the player list / length.
And let us know what happens / doesn’t.
If your room has a maxplayer that’s 0 (no limit) or more than 2, your method may fail, when 3 players get in.
tobiass:
Add a Debug.Log() and write some useful info to the console. Like the player list / length.
And let us know what happens / doesn’t.
If your room has a maxplayer that’s 0 (no limit) or more than 2, your method may fail, when 3 players get in.
Sorry what I mean is I saw this codes from a post in 2015. I try to copy it to my script. I then find out that I cannot type (PhotonPlayer newPlayer) PhotonPlayer won’t turn into blue. What am I missing here.
https://answers.unity.com/questions/1013437/start-game-once-2-players-join-photon.html
I think this code to make a wait-till-ready system is not working anymore. What should be the updated method in 2019.
tobiass
November 27, 2019, 8:54am
4
Assuming you use PUN 2 now, the code should use Player and PhotonNetwork.CurrentRoom.PlayerCount.
Thanks I just realize there is pun and pun2. I managed to get it works with a delay start tutorial I found.