Cloud Saves: Use LootLocker Player Files to Store Player Data in the Cloud

Unity
Author image
Johannes Fornaeus6 min read
Cover image

We live in a world where a majority of players play games across multiple devices and simply expect their game saves to "magically" follow them from device to device. As a game developer, we know this isn't as trivial as it might seem, but having a straight forward and flexible player cloud storage system is nevertheless vital. Some platforms might provide it through their tools and services, but a cross-platform solution is a whole other challenge.

Thankfully LootLocker's player files feature is a robust solution that empowers you to create and integrate comprehensive player file systems, including cloud saves, across multiple platforms in your game. And this functionality is easily accessible and managed through LootLocker's user-friendly web console interface.

Getting Started

Before you start using our Player Files feature, make sure that you have registered a free LootLocker account and have downloaded any of our SDK's.

Player files can be used for a variety of purposes, such as saving and tracking game progress, storing unlocked content and achievements, managing personalized character profiles, preserving in-game statistics and preferences, facilitating cross-platform gameplay continuity, and enabling seamless transitions between different devices. How you utlizie it in your game is entirely up to you and your game needs.

Handling files in the Web Console

In the web console you have the possibility to upload, delete and change revisions for a player. A player can have a max of 50 files and each file can be a maximum of 5 MB each.

Each time a file is updated, a revision for that file will be stored on our servers. So in the case of a players save-file being corrupted for example, you have the possibility as administrator to go in and revert the players file to a previous version if wanted. Since you also have the possibility to upload files, you can also modify the players file if needed as well.

LootLocker

Handling files in your game

File-operations uses the file_id of a file. A file gets assigned a file_id when they are created the first time. A file_id will never change for a file, so if you are often doing file operations on the same file, it's can be good to save the id of the file so that you don't need to download all the information for the players files every time.

Public files

When uploading a file, you can specify if you want the file to be public. When a file is marked as public, the URL for this file can be seen and used by other players. It can be useful if you're storing something like a profile picture for example.

Byte Arrays vs FileStream vs Path

In our SDK's, you can choose to upload files from a path or as a byte array or FileStream. Byte arrays and FileStreams stream the data without requiring storage on disk, creating the file during runtime. Uploading a file from a path stores the file on disk. The choice between byte arrays and path depends on the purpose of the file.

For cloud saves as a backup, using the path is typically the simplest option. However, in online games where the server provides most of the data, using a byte array or FileStream avoids saving anything on the player's device.

It's easy to switch between the functions, so if you started with one implementation you are not locked in the future to that specific method.

Uploading a file

Uploading a file is as simple as just calling the function with a path to the file or with the file-contents as a byte-array. When the file-upload has been completed you will receive a response where you can get the file_id if you need to use it later.

Here is how you would upload a file using a byte array in Unity;

And here is the same function but with an additional method that writes the file to a path;

Updating files

When updating a file, you provide the file id that you received when creating the file or when you get all the players files. If you are using player files as a backup system for your save files, updating the file from path is the simplest solution:

And when not wanting store anything on the players device, a byte array or FileStream is better:

Every time a file is updated, a revision will be stored on LootLocker servers, up to 5 revisions will be stored. As a developer, you have the possibility to select which one of these revisions that the player should receive.

Deleting files

Files can be deleted from a player. This action is not reversible, once a file is deleted, it can not be retrieved again. Make sure to implement the necessary feedback to be sure that the player is aware of this. Deleting files requires a file id, so make sure that you send in the correct one:

Getting a player file

The actual file is not stored on LootLocker, we store the URL of the file. So when you receive the response from LootLocker, you need to handle the downloading of the file yourself. But this is easy and simple to do with a simple Coroutine:

Getting multiple player files

Sometimes you want to check what files the player has. For example if you want to let the player choose between different save slots for example. Doing that is quick and easy with a single request:

Getting another players files

Getting another players files can be useful if you are using player files for things like profile pictures or similar systems. To do this, you need the ID of that other player. The ID of a player is returned when the player registers a session, it is up to you on how you implement the sharing of the players ID's between each other.

This function looks the same as the GetAllPlayerFiles()-function, but it requires a player ID to know what player to fetch the files from:

Conclusion

LootLocker's player files feature is a robust solution that empowers you to create and implement comprehensive player file systems across multiple platforms in your game. Whether you want to store player progress, achievements, personalized data, or any other player-related information, LootLocker provides the tools you need.

With our simple web console interface, managing player files is a straightforward process!

For detailed documentation on player files, please check out out our documentation).

To get started, try out our example game in Unity or explore the samples available in our SDKs. If you have any questions or need assistance, our team is here to help. Reach out to us on Discord or send us a tweet, and we'll be glad to assist you!

Stay up to date.

Join our newsletter and get these posts sent directly to your inbox.