Destroy master client player but not his scene objects.

I have a master client that has alot of instantiated scene items(They need to be instantiated because I want the master to be in controll over these objects so that clients cant remove objects from the scene, I am well aware of spawning them with rpcs). When the master client leaves I want to destroy the player object he controls but not the scene objects I spawned on him. So I turned PhotonNetwork.autoCleanUpPlayerObjects to false. But now comes the difficult thing how do I remove the player? There is no event that gives the previous master client. I did work around that removing the error of a missing behaviour script so I track who the master client was and let the master remove that player when the OnMasterClientSwitched event is called BUT the game of the master client still freezes when he closes the game. So what am I doing wrong any tips?

Comments

  • With instantiated scene items I mean PhotonNetwork.InstantiateSceneObject .
  • Hi @Gangafintie,

    if you use PhotonNetwork.InstantiateSceneObjects(...) and the MasterClient leaves the game later on, those scene objects will stay in the room until it gets closed (for example last client leaves the room or EmptyRoomTtl timeout). As long as the room stays alive, the scene objects won't get removed. This is different as PhotonNetwork.Instantiate whereat the object gets removed as soon as the owner leaves the room.
  • What should I pass in for the instantiation data? I know I need that for destroying the object so it cannot be null.

    PhotonNetwork.InstantiateSceneObject(_itemPath, _position, _rotation, 0, ??? );
  • You can pass 'null' unless you need Instantiation Data. It's not necessary for destroying or keeping the object alive.

    You can use Instantiation Data if you want to apply a different property to a scene object. A custom color for example can be passed using this data, making it available in the Awake function.