How I used Azure Mobile Services in my Unity game


 

In this guest post, Will Stieh (@WStieh) from The Karma Labs talks about how he and his team used Azure Mobile Services to create a global cross-platform leaderboard. 

Hello, I’m Will, and I am the lead programmer and creative director at The Karma Labs, an Indie game developer here in Canada. We have logopublished several mobile games, for Windows Phone 8, Android and iPhone all of which made use of Microsoft’s Mobile Services. In this blog post I will be talking about how we used a cross platform Azure Mobile Services implementation.

If you don’t know, Microsoft’s Azure Mobile Services is a backend server solution for mobile apps. It makes use of the Azure cloud server, and is very versatile in its use. It can be used for a simple leaderboard, or login information. For more information and tutorials, check out the official site (http://azure.microsoft.com/en-us/services/mobile-services/).

$logo-titledHere at the Karma Labs, we use Unity as our game engine. So when we began working with Azure Mobile Services, we had two choices. Either create our own cross platform plugin or find one. Luckily, a universal plugin exists, from Bitrave (http://www.bitrave.com/azure-mobile-services-for-unity-3d/). The plugin comes in two packages, a Windows Phone and Windows Store specific package and a universal one that covers iOS, and Android. Both are hosted on GitHub and updated regularly. The plugin supports all of the features of Mobile Services, you can easily insert new entries, update existing ones, read (including filtering results) from the server, delete entries, or securely login via a Microsoft Account, Facebook login, Twitter login, Google login or an Azure Active Directory. Both packages come with an example/in progress Unity project that you can reference if their documentation isn’t clear enough.

For our games, we used a mobile service server to host our leaderboards. It simply stores the player’s initials, their highscore, and their location (country code). Even though this is a relatively simple system, we were extremely pleased with how easy it was to get this up and running. It took us a few minutes to get the plugin setup, but the work on the Azure side took seconds. We created a mobile service, added a table and hooked in the plugin. That was it, we were able to push up our data and read it back instantly. We did play around with the idea of writing our own plugin but it ended up being more work than it was worth when a free and complete one was available

4         wp_ss_20140914_0001

Now, if you are not a Unity developer or would prefer to write your own plugin, you are in luck. After you have set up your own server the main page explains how to implement it in your app, or create a new app with it implemented. That’s right you can set up the server, and have it make an example app for the platform of your choice and then build from there. Platforms include, Windows Phone 8, Windows 8, Xamarin, Android, iOS, HTML/Javascript, and PhoneGap. The online tutorials likewise allow you to select which platform you’re working on.

Outside of the actual app, the server itself allows for customization. You can write custom scripts for each of the server’s behaviors (Insert, Update, Delete etc) within the server itself. You can use this to offload some work from your game to the server, for example leaderboard sorting. In our games, the app receives the top scores from the server and display’s them as received. The server itself sorts them from highest to lowest and returns only the top 10 or top 5. This is done by altering the server’s read script.

Hope that this blog post helps  give you ideas on how to use Azure Mobile Services in your next cross platform project. We plan to continue to use Azure in our games and hope to share more of our stories with you in the future.

Dat PhotoWill Stieh (@WStieh) is the Lead Programmer and Creative Director at The Karma Labs. A lifelong gamer, he started out on the N64. His favourite games are Knights of the Old Republic, Star Wars Battlefront, Halo and Assassins Creed. A passionate game maker, his dream is to build the next great game.

 

Want to try Azure at no cost? Are you a startup or small studio? Join BizSpark!

BizSpark provides free software, support, and visibility to help startups succeed. Get access to all the software you need including Visual Studio. Not only that, but you also get credits for Azure, so you can start getting your technology in to the cloud. Join BizSpark and become part of a global community that has over 100,000 startups in 100+ countries.

Comments (0)

Skip to main content