Search Unity

Question Removing a player from the lobby

Discussion in 'Lobby' started by cuddlepunk, Oct 5, 2022.

  1. cuddlepunk

    cuddlepunk

    Joined:
    Apr 9, 2014
    Posts:
    18
    I'm designing a simple multiplayer game with Normcore, and I was wondering whether this is an adequate method of removing players from the lobby?

    I've tested it a few times now, and occasionally the lobby states that the player is still in the lobby, even after their game instance has been closed.

    Code (CSharp):
    1.     // removes the local player from the lobby
    2.     private async void OnDestroy()
    3.     {
    4.  
    5.         string identity = AuthenticationService.Instance.PlayerId;
    6.         await LobbyService.Instance.RemovePlayerAsync(code, identity);
    7.  
    8.     }
     
    Last edited: Oct 5, 2022
  2. veleek_unity

    veleek_unity

    Ben Randall Unity Technologies

    Joined:
    Aug 25, 2021
    Posts:
    59
    That should be good enough. Are you not seeing any unhandled errors in the log when that occurs?

    When you say "the lobby states that the player is still in the lobby" are you referring to a different client that's in the same lobby?