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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Proper way to handle cliend/server disconnection (scene closed)

Discussion in 'Multiplayer' started by Max_power1965, Sep 21, 2022.

  1. Max_power1965

    Max_power1965

    Joined:
    Oct 31, 2013
    Posts:
    127
    I have a multiplayer game with 2 players.
    Assuming one of the players will kill the app or press the back button (change scene),
    1. how can I handle the logic to cleanup the scene from all the Networkbehaviours in common and avoid breaking the game?
    2. Is there any callback that should I use, I saw that there is OnClientDisconnect but, assuming the client press the back button and a new scene is loaded, then on the Host I'll have the OnClientDisconnect callback but is basically useless because the client it's already gone and I'll have a lot of errors on the client side because he changed the scene before