Transferring Ownership Before Disconnecting.

Sorry if this is a super noob question but I have an inventory system that is synced over the network. But if a client drops an item then leaves the server the items leave with him. Ive been trying to transfer the ownership of the Photon view but I cant seem to find the correct way of checking when the player is about to disconnect from the server. PhotonNetwork.connectionState doesnt get passed "Joined" when closing the program.

Comments

  • PUN usually cleans up objects someone instantiated when a player leaves. You can disable it by setting autoCleanUpPlayerObjects = false when the client connects. This will turn off autocleanup.
    You should make sure that the game does not run endlessly, because any instantiate will stick around forever and joining players will have to create all the objects unless you clean them up.
  • Hi Guys,

    I have similar problem but the solution mentioned here is incomplete for my purpose...

    I want to have a "Game" object that is present on each client all the time - one of players is master and updates special sections of code in "Game".
    Each non-master client after connecting to game reads its viewID from CustomProperties and assigns to his game instance for synchronization.

    Now when master client disappears - I want the game object still be present, untouched on clients machines then one of players that becomes new master - takes over the ownership of "Game" object.

    This works ok with - autoCleanUpPlayerObjects = false - "Game" stays at every client - one of them is taking the ownership - but there is also a problem..
    When some player leaves and rejoins the game again - there is still some data in the room about this player - I only do Destroy(gameObject) on Disconnecting player ..
    What method should I use in order to get rid of the disconnecting player completely ?? Now it looks like - when the leaving user rejoins I get several, same buffered "join" RPC's from him ( I use buffered rpc for instantiation instead of PhotonNetwork.Instantiate ).

    How can I clean disconnecting player completely with "autoCleanUpPlayerObjects" - off ??

    Thanks,
    Stan
  • Sorry for this thread ... I've just read about scene objects :D
    My "Game" will be instantiated as one..

    Cheers,
    Stan