I’ve got a turn based game that can be played head to head online. I’d like to be able to save the game state in playerprefs so it can be resumed after a disconnect. So I save the state after each turn.
The problem I’m worrying about is, if the player has two instances of the game running in their browser, they will save over each others game state as they complete turns, or I might even end up with a saved game that is a mix of two games. Am I correct in thinking this is what will happen?
How to prevent this?
The quick solution seems to be to not allow more than one instance to run, perhaps saving a time value (heartbeat) in playerprefs, that gets saved every 5 seconds, if a new instance tries to run and it’s within 10 seconds of the value in playerprefs it won’t run. Do you think that would be workable?
Thanks,
Stephan