How keep everything the same on disconnect?

I set RoomOptions.CleanupCacheOnLeave to false but all the instantiated objects seem to revert to how they where instantiated when my client disconnects (and reconnects).

I would like everything to stay the same as my game is a turn-based strategy game and if a player reconnects they should be able to continue with their units in the correct state.

Is there any way to stop anything from changing on disconnect since AutoCleanUp = false doesn't seem to do the job?

Best Answer

  • Tobias
    Tobias admin
    Answer ✓

    CleanupCacheOnLeave makes sure the objects don't get destroyed and removed from the server cache.

    When you rejoin, your client gets all Instantiate events again and this resets the objects.

    I think there is no way to prevent this except by modifying PUN itself. You could change the PhotonView registration code to keep the old objects instead of the new ones (the old get destroyed by default).

    You may also change the scripts that are observed by PhotonViews. You could hide instantiated objects until they get their first state update (after joining).

Answers

  • Tobias
    Tobias admin
    Answer ✓

    CleanupCacheOnLeave makes sure the objects don't get destroyed and removed from the server cache.

    When you rejoin, your client gets all Instantiate events again and this resets the objects.

    I think there is no way to prevent this except by modifying PUN itself. You could change the PhotonView registration code to keep the old objects instead of the new ones (the old get destroyed by default).

    You may also change the scripts that are observed by PhotonViews. You could hide instantiated objects until they get their first state update (after joining).