PUN2 - Change Master Client on Disconnect

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.

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.

1 Like

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?

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

1 Like

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.

Use SetMasterClient method.

https://documentation.help/Photon-Unity-Networking-2/class_photon_1_1_pun_1_1_photon_network.html#a8d829b36a02d2d92465860bd5f712dca

did you find the problem?

You can enable operations to occur when the player exits by changing the values of the CleanupCacheOnLeave command in the RoomOption settings.