(Multiplayer) Is it possible to switch hosts if a host disconnects?

  • From what I understand, one player is the host for a game, and other players connect to that player as peers. If peers leave, the game continues, but if the host leaves, all peers are kicked.

    What if I'm hosting a game with 3-4 players, and the game is designed so that it doesn't matter if one player leaves? If that leaving player is the host, the game would just shut down, even though that's not ideal.

    Is there a way to turn a peer into a host when this happens to avoid kicking other players?

    P.S: I'm aware of the dedicated server option, but as a solo developer with not a lot of money to pay for servers with I'd like to avoid that option if I can help it.

  • It's not currently supported. The main barrier to this is the high complexity of doing this. Your game would have to pick a peer, figure out how to transition the game state from peer-following-host to authoritative-host mode (e.g. by switching which event groups are active and transferring all other state used anywhere for any purpose in your game, including variables, behaviors, and so on), reconnect all other peers to them (if actually possible), and then resume the game once everyone is connected again (if everyone actually made it). It's the switching a peer to a host part that is probably toughest, will be a real headache to figure out, and if you make any kind of mistake your game will have weird bugs after the switch.

    A better approach is probably to use a centralised model instead, where a permanently running server is acting as the host.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • In theory (not in C3 tho). If host (as first player) leaves, you will be forced to drop connection, all users autonomously would select the second player, check if they can establish connection, if he's not - select third.

    But then...what if the original host didn't really disconnect? What if he just lost his connection for a short-period of time? 10 seconds and he's back, but players moved already to the second player who for example has worst internet. Would the game had feature of redirecting itself back to the original host if he's back? That's a lot of headache for developers with pretty small benefit for players too.

    I think implementing feature for hosts to pass their position to other players if they decide to leave would be better.

    Too much redirecting. It could be too huge depending on the game.

    This is not something developers practice often.

    If you just create your game to play with friends you don't really need this.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)