Search Unity

Save game across different apps

Discussion in 'Scripting' started by curtisrollo, Sep 13, 2017.

  1. curtisrollo

    curtisrollo

    Joined:
    Jul 12, 2017
    Posts:
    22
    Hey,

    I just have a general question to see how this can be done. I'm planning a language learning app, and want to keep track of the wordlist that players have been using.

    I am thinking of planning multiple game/ apps where players can register and keep using their word lists, so they don't have to start over when they move to a different game.

    I understand I might need third-party help, like PlayFab for writing save games. But I want to make sure this kind of cross-game saves can be implemented on iOS. Any other recommendation of services that I can compare with? Any way I can plan to implement this smoothly? Since player savefiles like this would be a massive list of vocab, would size be an issue?

    thanks,
    curtis
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
  3. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    PlayFab has a nice feature where you can do global user data instead of app user data. I haven't had a chance to mess with it, but it is suppose to allow your users to have data that can be accessed across apps. So, you could say, save your wordlist with one app but then access it on another app.

    The one advantage to using a backend service like Playfab is your user data there instead of just on a device where if the person loses their phone or something goes wrong, they would lose their progress. The other advantage is they could access it from multiple devices or even if they have an iOS device and an Android device and want to run the apps that way.

    Playfab does offer a free unlimited user tier(though they might cut you off if you get hugely popular) with some limitations, but might work out for your needs.
     
  4. SlyRipper

    SlyRipper

    Joined:
    Jun 19, 2012
    Posts:
    251
    I think of several ideas here you could use..

    How about a simple online database? Getting words and saving words into it. If you don't like that people have to be online to save their progress, then simply let them download larger parts of it. This way they can use them offline too, and saving them online makes sure that they can get the progress on another device via the database.

    There are also offline databases, you could save everything into that databse file and maybe upload that one, or the players have to copy&paste them onto the new device. Of cause you should encrpyt that file so the user can't play with the values in it to cheat some progress.

    Back in the good old days, while I used to play Warcraft3 a lot, they also had to come up with some saving ideas, as the progress could only be saved with an "image-like-backup" system. So basically you had a local savefile of the session you was playing. Most of the time this wouldn't work well, as you need all players in it again, that you've player with before. So to sum it up, they invented some code-based saving systems. You simply could enter some command like "-save" and the game showed a code (e.g. AK3l-d20k-22De-93kd) the next time you entered that code, the game could load every settings and levels and whatever you had earned before. So maybe this would do the trick, if you want to change to another device, simply get a code from the current app/device and enter it into the new one to load the word list..

    I hope I could give you some ideas on how to solve this ;)
     
  5. curtisrollo

    curtisrollo

    Joined:
    Jul 12, 2017
    Posts:
    22
    These are really good concepts, and can help reduce the save/ load portion. That the player can load / save a subset of the whole word list. I'm not sure how to actually code this, but I'll give it some more thought.

    Do you have any thought on which online database I can look at?
     
  6. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    Do you need this to be online? It's very easy to save a JSON file locally, and read/write the same file from multiple apps. If JSON won't work, it looks like PlayFab has pretty much everything you need: https://playfab.com/features/

    As for list sizes, I don't think that will be an issue unless you're running into millions of words. After all, a simple 64-bit C# list can contain over 260 million strings: https://stackoverflow.com/questions/3906891/what-is-the-max-limit-of-data-into-liststring-in-c
     
  7. curtisrollo

    curtisrollo

    Joined:
    Jul 12, 2017
    Posts:
    22
    Thanks. I think it's best to store online, as they may play the different games on different platforms, and want to access their wordlist. It seems my main bet should be PlayFab. I was wondering if I have different options, like one that won't cost me that much.
     
  8. SlyRipper

    SlyRipper

    Joined:
    Jun 19, 2012
    Posts:
    251
    The database could be any you want (mssql, postgresql, etc.). One of the most common ones are mysql, you could get a free webspace with an included database for testing (some might allow normal use, too). Simply connect to the chosen database and do the stuff you want (e.g. loading, saving words). I use some simple php scripts for that: UnityWebRequest sends a request to my php script, which connects to the database, gets the information and returns the response back to unity (you could also use a library to access your database from inside unity, but I like the php part, as php files commonly aren't viewable or downloadable, so your connection credentials are save ;) the unity app might get unpacked and show your credentials)

    You can get an idea on how it works here, you simply need to use the new WebRequest instead of the WWW class.

    P.S. If it's necessary you might want to encrypt the values being sent, and verify the source. That way nobody can cheat their results and you make sure only your apps can get data from your database.
     
    Last edited: Sep 14, 2017