Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question can i have non authoritative matches that dont depend on the host?

Discussion in 'Netcode for GameObjects' started by virtouso, Aug 11, 2023.

  1. virtouso

    virtouso

    Joined:
    Jul 12, 2013
    Posts:
    58
    in a game what happens if the host decides to disconnect? or loses the connection? does it mean the whole game drops?

    is there any way to save the game state on unity relay to continue the game even if the game host leaves the match by any reason?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,055
    Yes, if the host ends the game (whatever the reason) every client gets disconnected.

    There is no saving in that case. The host is gone, so is the game/match and its data. You can only fix this by using a dedicated server or by persisting every change to persistable game state as it happens.
     
    virtouso likes this.
  3. virtouso

    virtouso

    Joined:
    Jul 12, 2013
    Posts:
    58
    based on your answer, relays cant store any state. they are just broadcasters. right? they can only be used for private matches or coop modes.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,055
    A relay only serves the single purpose of allowing to parties to connect to each other without having to setup port forwarding on the host side. In a sense a Relay acts as a dedicated server that simply „relays“ all calls to and from a hosting client. Persistent storage is not the responsibility of a relay server.
     
    virtouso likes this.