A large portion of the game is the competitive nature of trying to compete with different players about setting the best times possible on the tracks. From our initial testing this was also found to be one of the most fun elements of the game that we wanted to push a lot.
To do this I was tasked with developing a remote service that would allow us to make a single shared leaderboard that all of the players would be able to push to with their best scores. This way the players would be able to view locally all of the best times for each track and what type of level they are at in terms of beating the best times.
Performing HTTP Requests in UE4
In order to communicate with the Dreamlo service from our project I needed to source a plugin that would let us construct and send HTTP Requests from inside of unreal. The plugin chosen for this job was VaRest. Once this plugin was incorporated into the project it was quite simple to construct these requests and send them as needed. Initially this was a concern that we might have to deal with a moderate amount of networked traffic, but this turned out to be a non-issue as we only have to send requests to the service when we want to display the leaderboard as well as at the end of the race when the players score is recorded.
Once I put together all of the queries that we needed to talk to the Dreamlo service the next step was to wrap this in a simple internal interface. This would provide a couple of public functions that can be called inside the game that encapsulate the process of talking to the remote server. This would make it easy to call things like "AddScore()" or "GetHighscores()" from different areas of the game. It was especially important to keep this interface simple and understandable as I wouldn't necessarily be the one calling these methods and other members of the team would need to understand how it would work.
I looked at some different solutions but ultimately ended up choosing Dreamlo as a solution to our problem. Dreamlo is a web service that lets you store simple text information for 5,000 leaderboard entries in your game. You simply have to send it a request with the relevant information and it will add a score to the leaderboard. You are also able to retrieve this information back again, and have access to some different sorting options.
The Dreamlo interface is similar to many other RESTful interfaces in that you deal with GET or POST request while including parameters in the URL you execute on. Some examples of queries that needed to be made to do things like add a new high score as well as retrieve a number of the high scores. There are options for different things like how many scores you want to retrieve from the top of the leaderboard as well as the format of the data that is returned. A bunch of supported formats include CSV, JSON, and XML.
The UI elements of the leaderboard were developed by Shane Gavin which included displaying the current high scores for the current track in the map select screen. It works really well and you can see the brief wait time when you request to see the high scores when it goes to fetch the data from the server.