Get Player Ready Check and Start Game.

Options
Hello Photon Community,

A player joins a random Room which is setup to 2 players, when the room is full i want both players when they selcted their character to press the READY button, after both player pressed the ready button the game starts.

currently i got when a player press the READY button that only the player gets on the play map. But the system should check if both are ready then send both at the same time on the map.

My current code which sends the player from the room to the map:
public void Ready()
{ReadyRPC(currentSlot, PhotonNetwork.player);}

void ReadyRPC(int currentSlotRPC, PhotonPlayer Owner)
{
//if (PhotonNetwork.isMasterClient)
//{
GameObject particleCamObj = GameObject.Find("CameraParticle");
particleCamObj.SetActive(false);
clientScript.ShowGameMenu();
//Destroy(charRectObj);

charSlotCount = 0;
....
...
etc

I found something on the internet and on the Photon Documentation with Hashtable but i cant quite figure it out how it works with my code.

Any solution is welcome, thanks for your help and time!

Comments

  • If I understood your intention correctly this is something easy to achieve . Make a variable readyPlayers=0 .
    Then when a player presses the ready button send a RPC to the MasterClient and increase readyPlayers by one.

    After increasing check if readyPlayers==2 if then Load the game level . You can set PhotonNetwork.automaticallySyncScene = true; then use PhotonNetwork.LoadLevel to load the level .

    If not set send another RPC this time to all clients to load the level.
  • Shadow690
    Options
    what do the Rpcs do