Hello, I just made a simple script that registers when everyone has chosen their team and then make the master client to send another RPC that will start the countdown. The problem is that playersReady is always 1 because it only runs the RPC locally.
using Photon.Pun;
using UnityEngine;
public class NetworkAvatar : MonoBehaviourPun
{
public static NetworkAvatar localInstance;
public int playersInRoom, playersReady;
private void Awake()
{
playersInRoom = PhotonNetwork.CurrentRoom.PlayerCount;
if (photonView.IsMine)
localInstance = this;
}
public void TeamChosen()
{
photonView.RPC("RPC_TeamChosen", RpcTarget.MasterClient);
print("team chosen locally");
}
[PunRPC]
private void RPC_TeamChosen()
{
print("RPC Called");
playersReady++;
if(playersReady == playersInRoom)
{
print("everyone's ready");
photonView.RPC("RPC_StartCounter", RpcTarget.All);
}
}
[PunRPC]
private void RPC_StartCounter() => RoomManager.Instance.StartCountdown();
}