Question from a developer:
What's the best way to use offline storage and keep data consistent with that in the player account in PlayFab?
Question from a developer:
What's the best way to use offline storage and keep data consistent with that in the player account in PlayFab?
The thing you'll need to decide for offline is how secure you want the game to be. We've got studios who go across the spectrum on this. Some examples of possible implementations would be:
Basically, if you're storing data on the client for a later sync, you can be guaranteed (for any non-trivial user base) that someone will modify that data to cheat the game. Realistically, there's no way to prevent that. So the key is, how important is it to prevent that behavior? In some cases it's not at all, while in others it's absolutely critical.
But in terms of the sync with PlayFab, what you don't want to do is store every change and try to then make a call for every one of them - that would push the client into making far too many calls in a short period (potentially causing the client to be throttled or temporarily blocked). What you'll want to do is aggregate the info on the changes, and minimize the calls. So for example, all the statistic changes can be aggregated and sent as a single API call. The same is true for User Data, for the save info.
Finally, in addition to (obviously) not considering the data "in sync" until you get a good response, you'll have to account for the case of a player who plays on two different devices, one in an offline state while the other is online. So the first thing to do when you log in, if the client has a local save that needs sync, is to get a User Data (or User Read Only Data) key which is always updated when there's a save. Check the timestamp on that (all user data is timestamped) and compare it to the start time for the offline data. If the data on the service is more recent than the start of the offline data, you have a choice - again, based on your game's requirements:
1. Present some kind of summary for each, and ask the player to pick which one they want to keep. Note that if you're using Sum, Min, or Max aggregation on any of your statistics, this will require you to do additional work to make sure this isn't a cheat vector.
2. Reject the locally stored data, and explain to the player that there's a more recent save online.
3. Aggregate the info between the current online save and the offline save. Usually not an option, since this creates an easy cheat vector unless you do all the work to integrate the two in a legitimate way.
Hi,
Amongst the 6 ways described here : https://stackoverflow.com/questions/34426570/best-way-to-save-data-in-unity-game
=> what would be the best way to save data locally so that' it's very easy to push/retrieve data from PlayFab with your API ?
For instance, what would it take if we are using PlayerPrefs ?
Thank you !
,Hi, when you say "What you'll want to do is aggregate the info on the changes, and minimize the calls. So for example, all the statistic changes can be aggregated and sent as a single API call."
=> I was wondering, what's the best way to save data locally in Unity to make it very easy to push/retrieve data from PlayFab ?
In this topic I can see there are up to 6 ways of saving data locally in Unity : https://stackoverflow.com/questions/34426570/best-way-to-save-data-in-unity-game
Does one of them make this synchronisation easier ?
For instance, what would it take to synchronise PlayFab with PlayerPrefs data ?
Thank you !
(As you will have noticed, I'm still very new to Unity, I'm just trying to choose the right methodology to have something "compatible" / easy to integrate with PlayFab)
Actually, that article would only confuse you if you're starting out. In it, 1 and 2 are just talking about saving data locally, 3 talks about saving to a server (as in our service), 4 and 5 talk about save format for ease of use, and 6 refers to using a local database.
If you're using Unity, then yes, PlayerPrefs is usually fine. The format for the save data can be whatever you need. JSON is very handy as a way to express complex data, so I'd recommend learning to use it for your projects.
3 People are following this question.