Search Unity

Third Party PUN2 - Change Master Client on Disconnect

Discussion in 'Multiplayer' started by Only4gamers, Sep 22, 2020.

  1. Only4gamers

    Only4gamers

    Joined:
    Nov 8, 2019
    Posts:
    327
    Hello everyone,
    I am new in Game Development and completely new in Multiplayer Networking. I am creating a Racing game and somehow I succeed to implement online multiplayer on my game using PUN2 and I am using Unity 2019.4.6f1. Everything is working fine except one thing. When Master Client is leaving the game, everyone disconnecting instantly. I searched everywhere but didn't find any solution. How to switch Master Client on disconnect and continue my game normally?
    Thanks.
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    Normally, PUN does not disconnect the other players, when one leaves.
    Something you do triggers this but we can't know what it is. Look out for calls of Disconnect and such.
     
    Only4gamers likes this.
  3. SirKnightDragoon

    SirKnightDragoon

    Joined:
    Mar 22, 2016
    Posts:
    23
    Normally Photon Pun 2 automatically changes master. If the master leaves, a client is automatically chosen to replace it.

    Did you compare your implementation with the demos that came with the unity package?

    https://doc.photonengine.com/en-us/pun/v2/gameplay/hostmigration

    Look here, he explains all that to you and also gives you methods to do it manually with some advice.
     
    Only4gamers likes this.
  4. junior52999

    junior52999

    Joined:
    Oct 17, 2013
    Posts:
    1
    How can I switch MasterClient at game time to another player? I'm looking if there's a way to set another player to MasterClient during game.
     
  5. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
  6. vahiktoro

    vahiktoro

    Joined:
    Oct 2, 2017
    Posts:
    1
    did you find the problem?