Because we’re a small independent developer with limited time and resources, it’s particularly necessary for us to be careful when determining how we spend our time. We’ve got heaps of new game ideas, and we don’t want to get bogged down developing one idea for months and months and months, especially when there’s no guarantees it will be a success.
We built Words and Sums and had it released to a global audience all within 8 weeks. There were many factors that contributed to the short development time, and in this article we’ll look at one major decision that saved us a lot of time, effort and money.
For context, Words and Sums is a word and number puzzle game where players compete in asynchronous multiplayer matches against opponents from all over the world. Asynchronous multiplayer games like this tend to present a common set of technical challenges. Generally speaking, you need:
These requirements call for a cloud based solution, and the solution we chose was Google’s Firebase.
Firebase is a suite of services that sits atop Google Cloud infrastructure, and takes care of a lot of the boilerplate work when setting up cloud based solutions. Importantly, many Firebase services can interact with each other, making it a stronger, more versatile solution as a whole. Firebase has a number of SDKs that can be integrated into an app, game or website, which amongst other things, eliminates the complexity when dealing with client-server communication. Using the Unity SDK, we were up and running with Firebase in a matter of minutes.
Before describing how we used the various Firebase services to solve our needs, it’s important to mention the Firebase pricing model as it was an important consideration for us. With Firebase you basically pay based on the amount you use each service. Crucially however, there’s a free tier that provides more than enough quota on each service to at least allow you to get your app released and into the hands of thousands of players without costing you a cent (depending on how efficiently you use the services).
So how did we use Firebase?
The combination of Authentication, Cloud Functions, Cloud Firestore and Cloud Messaging made it quick and easy to set up the core async multiplayer functionality.
We used Authentication to uniquely identify each player. Firebase's Authentication service can be used to provide 3rd party authentication (such as with Facebook or email address), but it can also be used in an 'anonymous' mode, allowing players to effectively play as a guest without the need for any player facing sign up or login process. The Firebase Authentication service also plays nicely with other Firebase services, in particular Cloud Firestore and Cloud Functions (which we'll describe further on).
Cloud Firestore is a fast and scalable NoSQL database option provided by Firebase. In Cloud Firestore, data is stored within documents, and documents are organised within collections. You can set up security rules for each document and/or collection to ensure the correct access is given to each read or write attempt.
For example, we created a 'players' collection, and inside that collection each user has their own document. The 'players' collection has security rules set up that ensure only an authenticated user can read or write to their own document, and no other player documents. This is done behind the scenes server-side by the Firebase Authentication system.
We also have a Cloud Firestore collection for matches, and within that collection, a document for each asynchronous multiplayer match that players are taking part in.
We used Cloud Functions to essentially set up a REST API that the client can hit, allowing the game to interact with the Cloud Firestore database. There are ways to write Cloud Functions so that the user specified in the request is automatically authenticated for you, once again ensuring you have a more secure server environment. We have a number of functions set up, including ones to submit round results, retrieve match states and also to update player info such as avatar and nickname. Deploying the functions we've written is simple, and once live, Firebase takes care of the scaling.
Our Cloud Functions also make use of the Cloud Messaging library, which we use to send push notifications to players when it’s their turn in the match. The same library methods work for sending push notifications to both iOS and Android devices, meaning it was a simple implementation to get all our platforms covered.
Dynamic Links was a fast and easy solution to allow players to invite their friends or family to a match. It takes care of the different scenarios likely to be experienced by the invitee. In the case they don't already have the game installed, the dynamic link can be setup to open the appropriate app store page. If the friend already has the game on their device, the link can directly open the game and be processed by the game to do particular things (for example, add the player to the match specified in the link).
To say Test Lab was useful would be a pretty sizable understatement. With Test Lab you can automate the testing of your Android or iOS app across a wide variety of devices and device configurations, and see the results (including logs, videos, and screenshots) in the Firebase console. Given the huge range of mobile devices that exist, particularly across the Android market, it was incredibly useful to test Words and Sums in an automated way on a broad range of common devices. While the Robo Tests we used were very basic, they allowed us to check that the game would start up and run properly on a wide range of Android devices. Within a minute or two we could run Words and Sums on multiple device configurations, and because the Firebase free tier includes some Test Lab usage, it didn't cost us anything.
Test Lab has also been really useful even after releasing Words and Sums. Soon after release we had a couple of users report issues on Android which we weren't able to reproduce on the devices we have in-house. Using Test Lab we ran the game on a wider range of devices and were able to reproduce the issue, identify the cause of the problem, and fix it as a result.
During the development of Words and Sums we also integrated Analytics, Crashlytics and Remote Config to make it easy to remotely monitor, configure and manage the game.
Analytics have been necessary to understand how players are interacting with the game, and they've been extremely useful when trying to ensure the game is balanced. In the case of Words and Sums, we've been able to use Analytics to check that when players compete against the AI, the AI is playing at an appropriate difficulty.
We've also used Crashlytics to improve the stability of the game. Crashlytics allows you to view crash logs in the Firebase dashboard, giving you information about crashes that players experience. The information provided (which includes call stacks with line numbers) is often enough to be able to identify and fix the problem. Since release, Crashlytics has helped us find and fix a handful of edge-case bugs in Words and Sums that only a few players experienced and we were unable to reproduce.
Remote Config allows you to make configuration changes to your app without needing to publish new app updates. Because of the integration of Remote Config in Words and Sums, we've been able to change advertising frequencies without having to release new updates, and also to notify players on old builds that there are newer versions available.
It's worth noting that while Firebase services worked well for us with Words and Sums, there might be other solutions that better address the problems you're trying to solve. We think Firebase is particularly useful in cases where you have multiple services that need to work together, but if you're just looking for an isolated system to solve a particular problem (for example, maybe you only want an analytics service), there might be better options available to address those particular needs. We believe it's always worth spending a little bit of time researching the options available, as a few hours of research up front can lead to huge time, effort and cost savings down the line.
Hopefully us sharing our experience with Firebase can be of some assistance to you as you work out what solution to use for the technical challenges you're facing.
Thanks for reading! Join the discussion for this article:
You can also contact us at firstname.lastname@example.org.