Master Client change

Options
Ive seen quite a few comments on this but every comment is the link to the page called "Master Client and Host Migration"
The page is no help because it gives the code needed but no mention of where it is put.
In my game it is the first person in the room that spawns the monsters. everyone else that comes in sees the monsters but as soon as the master client leaves the monsters disappear. Naturally i want to migrate everything to a new master client so that nothing disappears. If the code happens because the master client clicked a button then that is one thing. but what if he force quits the game. Then he didnt click a button.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited March 2021
    Options
    Hi @Michael_Watkins,

    Thank you for choosing Photon!

    It looks like the monsters are instantiated as player networked object and not as a room networked objects. Room networked objects remain in the room until it's gone and will be controlled and owned by the current Master Client if any. Read more about Ownership & Control.

    Implementing IInRoomCallbacks.OnMasterClientSwitched is optional and can be done anywhere.
    In fact easiest way is to override OnMasterClientSwitched from MonoBehaviourPunCallbacks. But for your use case you don't need this I think.

    In case a player wants to leave the room OR he's about to pause the application and he's the Master Client he can explicitly set next master client. Read here.
  • That ownership and control page has been the most important page EVER for me. Thank you. PUN is awesome