The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Get Player Ready Check and Start Game.

Kaymak
2016-03-31 16:59:44

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);

....
...
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

prince_of_persia
2016-04-01 09:54:18

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
2016-04-01 18:51:06

what do the Rpcs do

Back to top