I am trying to implement a leaderboard for my game in Unity. I found a tutorial on youtube that explains how to do that if you have a server that is hosting a database, using the WWW class to GET or POST to certain scripts on the server.
My problem is that I can’t really host that server 24/7, so I found a couple of services that offer free databases. One of them is https://mlab.com/ for mongoDB and i also found one with mySql. My question is how can I implement those things since there is no server kind of (hope i explained correctly).
Also, is there another way to do a leaderboard to see all players’ scores? (with login an stuff). Maybe what I am trying to do is a lot more complicated than what I need.
This is aimed at (with login an stuff)
I know this may not be the answer and probably over the top, if this is relevant, but one very important step in doing this is planning how to be GDPR compliant before writing a single line of code when creating a logging in system that may store identifiable information about someone. If it isn’t going to store any identifiable information then I reckon you’re okay if not then there are some things to consider :
Will they be logging in with an email account?
How will you protect the data transfer from client to server that contains sensitive information?
What if they forget their password?
How will they be able to prove they own that account?
How will you monitor the database for any breaches?
If your database gets breached, how will you notify all users?
That’s just off the top of my head, there are people that know loads more about this than I do.
If you can’t host your own server, you’ll have to find someone to do it for you. As far as I know, that generally means you’ll have to rent a server, since most people don’t let you run their machines 24/7 for free.
However, for testing/development purposes, I would recommend you download something like WAMP or XAMPP onto your local machine (in fact, for most of the development, I would recommend not using a release server). These packages come with a webserver host, a PHP environment, and at least one database environment; in both of the above it’s some form of SQL. Once you set all that up on your local machine, you can send requests (preferably POST for security reasons) to your PHP server to read/write your database.
If you’re keeping a database, you probably don’t really need to limit the size, especially if you’re just keeping a score and a name.
I will say, I don’t think there’s a better way than a remote database to keep a persistent and consistent leaderboard.
In any case, you absolutely need a server of some kind in order to do database-related stuff, even if it’s just on your local machine; again, if you can’t keep one running and you need the database to stay running, consider renting a server for the release version. If you can find a free service, of course, that works too.