Search Unity

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

Question Please help finishing network game.

Discussion in 'Lobby' started by VentaGames, Nov 21, 2023.

  1. VentaGames

    VentaGames

    Joined:
    Jul 9, 2021
    Posts:
    151
    Hi there,

    Before i explain my pain - I've read documentation, musing, etc. But still, I have issues.

    So, I have a 1x1 game. I'm using Netcode Lobby and Relay. One player is the host, and the second joins the lobby as a client. This works perfectly.
    Now, I have 4 scenarios:
    1. The host player quits the game.
    2. The client player quits the game.
    3. The host receives that the client has left the game.
    4. The client receives that the host has left the game.

    Basically, I need to shut down my network game for all 4 scenarios.

    Currently, I have a single exit function where I:
    1. Remove my local player from the lobby by calling: LobbyService.Instance.RemovePlayerAsync
    2. Disconnect my local player from the network: NetworkManager.Singleton.DisconnectClient

    Additionally for the host, I also Disconnect remote player using DisconnectClient

    Muse says that the Lobby should be deleted automatically when no one is left there.
    So, I subscribed to the LobbyCallback's LobbyDeleted, but this callback isn't called.
    Then i deleted the lobby by calling DeleteLobbyAsync, but then i got HTTP/404 error in the console.
    So, when the user creates another lobby and starts the game, no one can connect to this game.
    It seems that something hasn't stopped/removed.

    I'm fighting this a god damn a week already.

    I'm kindly asking you to help. I just need the steps to quit the game and stop the network game from both: the client and host.

    +200 to Karma, who will explain it to me.
     
  2. UnityKristy

    UnityKristy

    Joined:
    Mar 9, 2014
    Posts:
    6
    Instead of calling NetworkManager.Singleton.DisconnectClient, can you try having each player call NetworkManager.Singleton.Shutdown() when they quit the game?