short time where there is no master client

Options
I have a 2 player game where the master client instantiates scene objects. Code is something like
void MakeUnit(){
if(PhotonNetwork.IsMasterClient){
//instantiate scene object
}else{
//send rpc to other player (presumably the master client) to tell it to create a scene object
}

Works fine most of the time except I have found that if the master client disconnects just before the other players tries to make a unit, then the unit is never made. It appears that there is a short amount of time between when the master client disconnects and when the other player realises it is now the master client.

How do you deal with a scenario like this?

Thanks

Comments

  • Tobias
    Options
    If any client runs into a timeout, the connection fails and messages to the user or from the user are lost. It's ugly, when this happens to the Master Client.

    You can send all required info to everyone, even if only the Master Client should act. This keeps everyone up to date and you could calculate what needs to get done in the background.

    When the Master Client timed out, the server will assign a new Master Client. There is a callback for Master Client changes on the clients, so this would be your place to react to this.

    I think for unit generation, I would just let the Master Client react to OnPlayerEnteredRoom(). When this happens: Create the units.
    If the Master Client switches, the new one should check if everyone has all the units needed.