RPC Call for Round Countdown Executes Late on Remote Clients

I’m using an RPC call to initiate the pre-round countdown for my multiplayer game (PUN), but the countdown doesn’t begin on the remote clients until it’s finished on the master client.

public void roundCountdown()
    {
        GetComponent<PhotonView>().RPC("roundCountdown_RPC", PhotonTargets.All);
    }

    [RPC]
    void roundCountdown_RPC()
    {
        roundStartScreen = GameObject.Find("RoundStartScreen(Clone)");
        roundStartScreen.transform.GetChild(0).GetComponent<Text>().text = "Round Starting In";

        
        InvokeRepeating("decreaseTimeRemaining", 1.0f, 1.0f);

        if (roundCountdownTimer == 0)
        {
            Debug.Log("roundCountdownTimer = " + roundCountdownTimer);
            startPlayer();
            HUDCanvasGO.transform.FindChild("RoundTimer").GetComponent<RoundTimer>().hasStarted = true;
        }

    }

Could someone explain the reason that the countdown executes on the master client (the only client that can start the round without a full room) and THEN the other clients? I thought PhotonTargets.All meant that the target function would be run on all clients at approximately the same time.

PhotonTargets.All uses a “shortcut” and executes the RPC instantly on the local client. The others get it a bit later, when the message got through the network.

You can use PhotonTargets.AllViaServer to send the RPC back to the client which called it.

The script InRoomRoundTimer.cs could be interesting to check out, too. It sets a property when the game starts. Based on this, rounds start over and over again, but you can also just use it to initially start your game.