RPC's don't work (PUN2)

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

go there and ask, you’ll get a response within minutes

Thanks! I was actually searching for a PUN server but every server invitation I found has expired :confused:

yeah it’s easy to forget that tiny little foldout option that changes the invite duration… discord ui

The RPC call is odd. It targets only one player:

photonView.RPC("RPC_TeamChosen", RpcTarget.MasterClient);

Send it to All.

The Asteroids Demo from the PUN 2 package has a screen where players signal “ready” or not.
There is also a Teams extension to PUN 2 in the UtilityScripts, which might be useful.