I’m building a round-based multiplayer game using Photon Unity Networking and I’m having issues with my countdown timer. I’m currently trying to use an RPC to start the timer on all clients, but something odd happens. When I start the timer, it runs on the master client first, then when it’s completed the countdown on that client, THEN it executes on remote clients. Here’s my code:
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;
}
}
I’m calling roundCountdown() through a button press for testing purposes. I’ve tried changing the PhotonTargets to Master and AllBuffered with the same result. I truly don’t understand why this causes the countdown to finish on the master before executing everywhere else. Can someone explain the logic here? Am I just completely doing it wrong or what?