3
\$\begingroup\$

I am building a multiplayer game with a team and each player will have a multiplayer rank, a matchmaking rating (MMR), a username, and possibly a picture, a description etc. We are planning on delivering the game on multiple platforms such as Steam, itch.io and GoG.

Since I am using Unity, how can I store and retrieve such data independently of the platform ? Is there a builtin service provided by Unity or do I have to create some SQL database and code all of the logic to use it ?

\$\endgroup\$
4
+50
\$\begingroup\$

Unity does not include a server side persistence solution out of the box. As far as I can tell the only storage solution Unity includes is PlayerPerfs, but that is client side.

However that does not mean you have to create a SQL database. Some games use services that provide a nice interface for NoSQL databases (for example MongoDB via GameSparks or DynamoDB via Amazon). You may also get a web hosting with a SQL database and build a custom API. You may also setup your own servers if you have the know-how.

From a security stand point, if you are accessing the database directly, you will have the credentials in the client, and there could be ways to intercept the traffic. Intead use (or create) an API that allows players to authenticate with an account, and allows the client to call function or microservices with the session of the player. Then in the server side, you will have the database access logic. Also, make sure you are getting a connection to the server over a secure channel.

If you are getting a web hosting or setting up your own server, make sure to get a domain, setup HTTPS (you can get a certificate from Let's Encrypt), you will need to implement access control and of course the database abstraction.

With GameSparks you would setup their authentication system, and use Cloud Code (JavaScript) to access the server database (tutorials available on their website, start with the Unity Setup).

With Amazon, you can use Cognito for authentication and user data, and if you need something more involved you can use AWS Lambda (JavaScript, C#, Java, Go or Python) to access DynamoDB (see the AWS SDK for .NET, nugets available).

Whatever it is you choose, it is common wisdom to abstract it and isolate it, make sure it is easy to replace.

\$\endgroup\$
  • 1
    \$\begingroup\$ To clarify, it's not against the rules to mention specific technology in the context of describing how to solve a problem. We like questions to focus on the problem being solved rather than just asking for lists of tech, but that doesn't make tech off-limits as part of an answer. Just be sure the answer includes some detail about how to solve the problem with that tech or why it's an appropriate approach to the problem, and disclose any personal connections to it (eg. if you are the author or an employee of the company creating the software) \$\endgroup\$ – DMGregory Jul 30 '18 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.