- Home /
set otherplayer as master client when master client leaves room photon
set other player as master client when master client leaves room photon ??
How its possible ?
Thank you
I'm also looking for how to change the MasterClient in real game time, even if the first MasterClient hasn't come out.
Answer by Bunny83 · Aug 19, 2021 at 03:41 PM
Host migration (which is the buzzword here) is a quite complex topic. As you can read in the photon docs:
There is no generic solution in Photon for "Host Migration". However, we make things much easier for you.
Also:
Photon does not hand all information that the former Master Client had about the room's state to the newly elected one.
So you have to handle most things yourself. What exactly soley depends on your own architecture. There are two main scenarios that need to be distinguished:
The host suddenly lost the internet connection.
The host is actively promoting one of the other clients to become the new master.
The first case is much more difficult because in order for a client to take over as master, every client has to have a copy of the whole gamestate. This is generally actually not a good approach for most games since it's usually the master / host that has certain secret information that would give cheaters an advantage. The host / master could always cheat. However if the whole gamestate is always shared with all other clients, everybody could see any information there is about the game.
The second case is a lot easier since the current master can actively send the relevant data to just one client. This can be done either on command or when the host actively clicks a disconnect / leave button. Of course such a migration would not be possible if the game is force-closed. For example for WebGL builds force closing is the most likely case as people would simply close the browser tab.
As I already said, noone can tell you what information the current master should or have to send to the newly choosen master. That's up to your game.
Your answer
Follow this Question
Related Questions
Photon SceneObject Creating by Client 0 Answers
What is master server in unity is it okay to use it in my multiplayer?? 1 Answer
Photon Instantiate object not disappear after dc master client 0 Answers
Photon enable/disable objects on all views? 1 Answer
Can I disable UI visibility for the LOCAL player and not other players? (using photon) 0 Answers