What happens networked GameObject's ownership when master client disconnects?

Options
Hi, I'm creating simple multiplayer game with Photon. When player disconnects, especially Master client does, every GameObject instantiated from Master is gone, so I added this code for prevent it:


PhotonNetwork.autoCleanUpPlayerObjects = false;


Now GameObjects are still there even Master is gone, but what about their ownership? I needed to destroy some of them when they needed, like dies, but if Master is gone and other player got selected as Master, is he automatically get ownership of them too?

If not, is there a way to do that automatically? Thanks!

Best Answer

  • Romin
    Romin
    Answer ✓
    Options
    Hi @modernator
    first of all if you want gameobject to stay after master client is gone you should use Photonnetwork.InstantiateSceneObject() instead of PhotonNetwork.Instantiate that way the gameobject ownership will be transferred to the next master client and the gameobject will not be destroyed if master client leaves

Answers

  • Romin
    Romin
    Answer ✓
    Options
    Hi @modernator
    first of all if you want gameobject to stay after master client is gone you should use Photonnetwork.InstantiateSceneObject() instead of PhotonNetwork.Instantiate that way the gameobject ownership will be transferred to the next master client and the gameobject will not be destroyed if master client leaves
  • modernator
    Options
    Thank you. That's what I want know exactly :)