Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Host Migration Options

Discussion in 'Netcode for GameObjects' started by RobertGrospitch, Jun 9, 2021.

  1. RobertGrospitch

    RobertGrospitch

    Joined:
    Sep 8, 2020
    Posts:
    7
    Hello All,

    I was wondering if there were any options for host migration on host quit. I just just wrapped up my mobile 2D shooter game and am ready to start polishing.

    Is there currently any ability to migrate host (while using photon Realtime transport layer).

    I know that UNET had some options for Host Migration.

    If not I will go ahead and look for other options.

    Thank you!
     
    hippocoder likes this.
  2. luke-unity

    luke-unity

    Joined:
    Sep 30, 2020
    Posts:
    306
    We don't have any built in host migration for MLAPI currently.

    There are some ways you could add host migration to a game using the Photon Realtime Transport. Something along the line of the following should work:

    1. While still all clients are connected use a NetworkVariable to agree on a fallback client which will be next in case of the host disconnects.
    2. If the host disconnects have that that fallback client create a new room with a slightly different name like "<old-room>_1" by starting MLAPI again as host with a different room name and have all other clients connect again to that new room.

    To get that to work the fallback client will need some way to store the current game state when stopping MLAPI and spawning the right objects again when entering host mode after the migration.
     
    nico_st_29 likes this.
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'm a bit confused by this. Why do we need to work with Photon? And you mentioned "currently" which implies that Unity has a plan for host migration?
     
  4. luke-unity

    luke-unity

    Joined:
    Sep 30, 2020
    Posts:
    306
    Oh I was not trying to imply that we have plans for host migration. You could do the host migration approach I mentioned with any transport but the procedure is much easier if the transport is relay based and has a concept of rooms. The reason why I mentioned Photon is because the OP mentioned that they are using the Photon Realtime transport.
     
    Last edited: Jul 9, 2021
    hippocoder likes this.
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Thanks, I was mixed up because the MLAPI sample also requires Photon, just trying to wrap my head around things.
     
  6. hippocoder likes this.
  7. amirhosseinasa

    amirhosseinasa

    Joined:
    Nov 30, 2022
    Posts:
    4
    Hi,
    Did you find any solution?
    Hi,
    Did you find any solution?