question

James C. Smith (MobilityWare) avatar image
James C. Smith (MobilityWare) asked

Best practice for caching and off-line

What best practices do you recomend around caching and playing off-line?  I don't mean anything as advanced as spending virtual currency while off-line. I am thinking of a simple PlayFab integration where I am mostly using PlayFab to just:

  1. Give me some basic KPIs and like DAU, MAU and retention
  2. Use Title Data as a way to adjust tuning and balancing issues in the game
  3. Use the Title News to send messages to my players about new updates and new games. 
  4. Track some player stats to have global and social leaderboards

I don't have IAP or VCs or catalogs.  I want my game to work while offline.   I understand you are considering offline support on your roadmap but I want to understand what I can do today.

For #1 it would would be okay to not include off-line play in the KPIs. That is not ideal but it can work.

For #2 I need to know the values of the title data even when offline. I guess I need to build my own system for caching the last known values that were downloaded and having defaults if none were ever download.  Do you have example code that makes this easier? I am writing in c# for unity.  Or do you have pointers about best practices for doing caching like this?

#3 is simple. Just don't show news if off-line 

#4 obviously I would not display a leaderboard when off-line. But I would want progress made while offline to be stored in stats.  I guess this is where things get murky and dangerous.  

 

All of the above may even be too specific. I would love to just hear about how games like AdVenture Capitalist use PlayFab and work off-line.   Assuming I am making a game that will allow off-line play, which PlayFab features are reasonable for me to try to use and what best practices should I follow to use them?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

When it comes to caching for offline play, your best bet from a technical standpoint is to keep a local store of the values that you need for gameplay, updating them as play proceeds, and then upload the final version when you're next online, making sure to stage out those calls so that you're not attempting to hit the service with dozens of calls at once from a single player.

In our samples, we use PFSharedModel to store data retrieved from the service, for later use.This is still a work-in-progress, as we have a number of updates we'll be making to it, but it's a great place to start for the fundamentals: https://github.com/PlayFab/UnitySDK/blob/master/PlayFabCombinedTestingSample/Assets/PlayFabSDK/Examples/API/PfSharedModelEx.cs.

We don't currently provide client-side caching of events and player data/stats, but we do plan to add that as soon as we can.

Now, the deeper question is, what should you allow when players are offline? This is a very game-specific decision, as each game will have its own motivating factors for players.

When it comes to basic metrics on your players, you're correct that DAU, MAU, etc. depend upon getting events from the user to the service on the day in question. This is partly due to the fact that the client's clock can't be trusted to be accurate (which could throw off your calculations for the user) - changing the clock time on a device in order to speed up some in-game reward or action is exceedingly common. However, it's still extremely valuable to log player behavior info, for later upload as events. That will give you what you need to be able to do segmentation on users for the way they play the game, and let you see what things people do more often (or less).

The tougher question is around player progress data and statistics. Anything you store client-side is vulnerable to hacking. So storing data locally means knowing that, if you have any non-trivial number of players, it will be cheated by some players - it's essentially guaranteed. For some games, like most clickers, that's not an issue since they're largely not concerned about player competition. But for games where competition is a key component, having players who routinely cheat to have more/better equipment than others can be extremely detrimental to your retention, as well as a community management nightmare.

So the answer to the best practice question is really, what are you willing to give up security over? Any data or statistics that you don't need security around would be fine candidates, and it's a simple matter to keep it up to date locally for when you come back online (so that you can just send up the latest version). The alternative is to provide a different gameplay mode while offline, so that players can enjoy your game mechanics without jeopardizing your game's community.

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

gabebigboxvr avatar image gabebigboxvr commented ·

Is this still the best practice recommendation?

0 Likes 0 ·
brendan avatar image brendan gabebigboxvr commented ·

We're looking into adding caching for offline play at a later date, but yes, for now this would be the recommendation.

1 Like 1 ·
countinglampposts avatar image countinglampposts commented ·

That example link is broken. Is there an example out there I could review?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.