Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party How to close room when master client leaves? Photon PUN

Discussion in 'Multiplayer' started by Paulx774, Jul 8, 2021.

  1. Paulx774

    Paulx774

    Joined:
    Mar 18, 2021
    Posts:
    103
    I want to make a feature like Photon Bolt where the host leaves the room, everyone disconnects. In Photon PUN, when the master client leaves the room, a new client is elected as the new master client. Instead, I want the whole room to be closed. How can I do that?
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Every client checks who is leaving. If the current Master Client leaves, show a dialog and call PhotonNetwork.LeaveRoom().

    It might make sense to close the room via:
    PhotonNetwork.CurrentRoom.IsOpen = false;

    You can do this early (when everyone is ready / the game starts) or when the Master Client dropped (wait until the server acknowledged this change).
     
    Paulx774 likes this.