I’m working on an online, 1 vs 1 game, and have one spot in my code set up like this:

int enemyLeaderIndex;

Start()
{
    //RPC Call to set the OTHER PLAYER's enemyLeaderIndex
    Debug.Log("Enemy's leader is: " + allLeaders[enemyLeaderIndex]);
}

Obviously RPC’s have lag, which will change from computer to computer, but just can’t run as fast as the normal, not-online code. So is there a way to make my code WAIT until that RPC call is finished? I know RPC’s can’t return a value, but I’m unsure if simply waiting a frame (“yield return null”) will be enough even on slower connections, or how wait for the RPC reliably

I figured it out. I set up the code like this (again keeping it as simple as possible):

int enemyLeaderIndex = -1;

Start()
{
    //RPC Call to set the OTHER PLAYER's enemyLeaderIndex to a value of 0 or greater
}

Update()
{
    if(enemyLeaderIndex > 0 && haventAlreadyDoneThisYet)
    {
        doStuff();
    }
}