Saturday, 28 June 2014

Leaderboards

I have spent the last couple of weeks fighting with implementing leaderboards into Star Diver. There will be a leaderboard for each level. When the player achieves a perfect score (ie. removes all formations) then their time is posted. Obviously lowest time wins, and because I capture this in milliseconds I shouldn't get too many collisions.

Technically there are lots of options ranging from building your own database and website using something like Azure, using a dedicated subscription based solution or using one of the more publicly available options such as Google Play Games. After spending a couple of days deliberating on this I decided to go for Google Play Games, since my initial target platform is Android, and by definition everyone with an Android device that can download Star Diver from the Google Play store will have a Google account already. Also Google+ is gaining in popularity rapidly which will soon make the use of "frienly circle"  leaderboards there useful also.

I then needed to find a solution to integrate with Unity. There are literally dozens of solutions out there for doing this, and I was not inclined to develop my own from scratch.

The first I tried was the Open Source Google Play Games plugin for Unity, available on GITHub. This worked well and took about one evening to put together, however after I implemented it I realised that the only UI available for displaying the leaderboards was the public Google Play Games UI. This did now fit with the look of my game at all, and I started looking at ways to implement a custom UI.

I then spent a night researching alternatives in the Unity Asset Store and came across and purchased the excellent Android Native Plugin by Stan's Assets. This is amazing value at $30 and includes not just the GPG integration I needed, but also In-app purchases (which I need to to later anyway), Facebook integration and Native Android pop-ups. All the user reviews were generally positive and this swayed me.

Here is the result from a look and feel point of view. I like it better than the standard Google one, but it might need a bit more tweaking later.


I had to contact Stan a few times to get things working, however he responded extremely quickly to all my queries and after some teething trouble (which meant I had to remove the Facebook functionality) it worked.

Setting up the Google Developer Console with all of the levels and understanding how to publish the GPG portion vs. the actual game took another few days to get right. The fiddly scrolling table to actually show the scores and artwork for the window border took me another few nights. But it's done now. Phew! I can't help but think that there are still a few sneaky bugs in there, since my scores appear to miraculously vanish occasionally...

Overall I learned a lot, but a couple of weeks to get one feature working was a bit harder than I originally thought.


No comments:

Post a Comment