Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Best way to store player's inventory?

Discussion in 'Game Design' started by FunBenjamin, May 26, 2019.

  1. FunBenjamin


    Oct 31, 2018

    I am making an offline 2D mobile game. I am struggling about the inventory. The player can buy gold with real money. And the player can use the gold to buy items in the game.

    I just don't know where/how to store the player's inventory (gold and items).

    Right now it is in a dat file. I was thinking about storing it in a web database, but 250 $ for a month is too much for me. Another solution is a client side database, for example an mdf file. What is the recommended? Or is there a cheaper web database somewhere?

    And also if the player loses his phone, everything will be lost if I store it on client side. I don't know if this is a huge problem or not.

    Thanks for the replies!
    Last edited: May 26, 2019
  2. TonyLi


    Apr 10, 2012
    If players pay real money, their data must be secure and reliable. Client-side won't suffice.

    You can get an entire virtual server (databases, web hosting, etc.) often for around $2.50/month. Is that what you meant, or did you really mean $250 USD/month? Check deals on budget hosts like Hostgator and Bluehost.

    Securing players' data is up to you, though. It has to be secure in-transit (e.g., SSL) and in storage (e.g., in your database). If you don't know how to implement that, you should hire someone.
    angrypenguin likes this.
  3. Tiny-Tree


    Dec 26, 2012
    playfab could be an option, its free if you dont need all the features, else cloud saving is free for mobile devices
  4. RobAnthem


    Dec 3, 2016
    I don't know what platform you're using (IOS or Android) but if you use Google Play Games, you can use Google Save Games which lets you save data on the Google cloud tied to the users account. One of the main reasons Google provides this is because they REQUIRE you to be able to restore any purchases made by users. It's complicated to setup because you are passing bytes and not raw data. So you'll have to parse the bytes, but it is effective. However, if your items for your players inventories have stats that can change, it will be much more difficult. It's one thing to save a list of item ID's and reconstruct the inventory at runtime, its completely different to save the actual item data and reconstruct the items at runtime. Legally you are only obligated to restore the gold your players purchased, but no one will be happy with that.

    Otherwise you'll need a server like you were thinking, which is also complex because you'll need to get a certificate and authorize it server-side to prevent unwanted access to your server. SQL would be your best bet though, or SQLite, but SQLite has a data limit, so if you expect your game to be huge and have lots of data then SQLite is not a good fit.