Hi, I'm Henry. In 2012 I quit my job as a programmer at BioWare to spend a year making my own indie games. This blog is about what happened next...

Like Spaceteam? Want to support my work?
Join the Spaceteam Admiral's Club!

The Last 10%

“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time” — Tom Cargill, Bell Labs

Beta Testing!

Spaceteam 2.0 is getting close. My translators have started testing and if you would like to help test, dear reader, then you can sign up here:

Beta Test Sign-up: [CLOSED: I have enough testers for now, thanks!]

I’m using a service called HockeyApp which helps me distribute builds so don’t be alarmed if you see references to it after you sign up. You can report bugs here:

Bug Tracker: https://bitbucket.org/hengineer/spaceteamunity

There are a few outstanding features that I have yet to add:

  • Acknowledged Mode
  • Ship’s Cat
  • Admiral’s Challenge special achievements

…but I wanted to test the main game as early as possible.

New Features

I tried very hard not to add any new features during the rebuild but there were some things I basically got “for free” with Unity, and a few others that I decided were worth it.

  • Slightly nicer graphics
  • Multitouch (finally!)
  • A “Play Again” button
  • QR code scanning on Android
  • Dutch, Greek, Turkish, and soon Arabic translations (many thanks to my volunteers!)
  • Downloadable Content — Optional assets like ship skin upgrades can now be stored on a server and only downloaded when needed. Now that I know how to do this it’s going to be pretty useful for my future games.
  • Analytics — Will help me estimate how many people are playing and also record certain things that happen in the game, like highest level reached. I’m hoping I can use it to create automatic high score leaderboards for special events.
  • “FailCam” — An (optional) fun feature suggested on the forum where the game takes a photo of your face at the moment of failure. The photos are then displayed on the Game Over screen as a memento of your accomplishment.

FailCam in action

I’ve also had to make a few sacrifices:

  • The first release will be Wifi-only, I haven’t had time to add Bluetooth yet.
  • The game runs more slowly on older devices. I’m still hoping to make some optimizations but I think this is price I have to pay to keep up with technology.

The 10%, or what’s been keeping me busy

Just finishing all the little corners of the game has been a slog, and then some unexciting things that took longer than I thought. The details are boring, but for what it’s worth.

  • Japanese font + symbols. I made some trade-offs between build size and flexibility and ended up treating Japanese differently from all other languages.
  • System Dialogs/Alerts. None of the plugins I tried did what I wanted so I made my own using Unity’s UI system. This turned out to be much easier than I thought but I wasted a bunch of time playing with other systems.

More New Plugins I’ve Discovered

Lunar Mobile ConsoleVery useful. It shows a debugging log on the device itself so you can immediately see errors or warnings. It’s easier than attaching a remote log viewer (I’ve been using Editor Console Pro for this) but more importantly it allows external beta-testers (eg. you, maybe?) to send me the log output by email. Getting a log file manually from a user’s device is a huge pain otherwise.

Build Report ToolSimple and effective.

Preparing For Launch

I’m speaking on a panel at Casual Connect in San Francisco in mid-July so I’m using it as a self-imposed deadline. If all goes well then around that time I’ll be launching:

  • Spaceteam 2.0
  • A new website that unifies the game, the Admiral’s Club, my blog, and all the spin-off projects like the board game and Spaceteam ESL.
  • A new Patreon campaign. The Admiral’s Club will start accepting new members, so people who missed out on the Kickstarter will get another chance to join. Existing club members will have no pressure to subscribe, but I’ll talk more about this in a future blog post.

See you soon!

Unification is Approaching

I’ve been making a lot of progress on the Spaceteam Unity rebuild but there’s still work left to do. Here’s what it looks like running in the Editor:

I’m frustrated by how long it’s taking because I really want to be working on Blabyrinth, but I’m still confident this was the right decision. I get emails every day about the game not working on various Android devices.

I’m surprised about just how much stuff there is to rebuild. I still think of Spaceteam as a small, “simple” game but it actually grew quite a lot over the last 3 years with all the upgrades, Admiral’s Club additions, new languages, and spin-off projects.

Challenges I’ve encountered:

  • Unity’s NetworkLobbyManager reloading the scene when a connection is made. I don’t want this to happen but I haven’t been able to prevent it. When the scene is reloaded various objects get reset/recreated and I have to restore their state in such a way that it looks like nothing happened. It also causes the animation to visibly stutter.
  • Publishing an iOS project and then compiling and installing to a real device is slow enough to be very frustrating. At the moment I’m trying to fix problems that only show up on the device and the iteration cycle (change, build, compile, test, repeat) involves so much waiting that it’s very easy to get distracted doing something else.
  • Slime effect (+ wiping). This was tricky even in the original game because it involves RenderTextures and custom shaders, but I had to relearn all that stuff in Unity so it was a bit time-consuming.

More C#/Unity Gotchas:

  • SyncVar objects seem to need a default constructor, or you’ll get weird errors. My OutfitPiece class had a custom constructor and it took me a while to figure out that simple adding an empty OutfitPiece() constructor made the errors go away.
  • To make the dangling panels I naively figured that adding a Hinge Joint to the object would be enough, but I also needed to add a Box Collider (despite not needed collision) or the panel wouldn’t be affected by gravity properly.
  • If you want to Join a List you have to use ToArray() first
  • When calling a coroutine from C# you must use StartCoroutine(coroutine) or it will just silently fail! My solution: I’ve been suffixing all my coroutines with “Coroutine” and making one-line helper functions that simply wrap the call.
  • If you try to override a function but don’t include the “override” keyword sometimes it will fail silently with no warnings.
  • C# does not autoconvert Doubles to Floats. Must always add “f” at the end of floating point values. Mildly annoying.

New Plugins I’m using:

  • ZestKit and now DOTween. Many of my animations are dynamic so I needed a programmatic solution for smoothly animating between different states (“tweening”). I started with Prime31’s GoKit/ZestKit but due to lack of good documentation I ended up switching to DOTween.
  • Procedural Lightning. I wanted a good shock effect for electric malfunctions, so I found a cool library for lightning bolts. Looks great and very easy to customize.
  • QR Code Scanner/Generator for the Admiral’s Club login page. I only used a few bits of code from this library but it got me on the right track.
  • Prime31 Etcetera. For showing native iOS and Android dialog boxes.
  • TextMesh Pro. I needed a way to modify individual characters in a label (eg. for Labelling Malfunction) and TextMesh Pro seems to have a lot of features. I’m still experimenting with it.
  • More Post-Processing Effects. I’m using this for wormhole and anomaly screen distortion effects like rippling and waving.

So it’s going to be a few more weeks of work at least to get the original game done, and then I have to re-port Spaceteam to Apple TV (as a bonus Chromecast/Android TV should now be much easier). Then Spaceteam ESL and the upcoming Spaceteam FSL. Spaceteam Kids is still in the works as well.

Whew! That’s a lot of Spaceteams. I’m trying to stave off the madness by filling in the cracks with some Blabyrinth development.

Space out!

The Spaceteam Networking Post

Many people have asked about the networking in Spaceteam, so it’s about time I wrote an official blog post. However, I’m currently rebuilding the entire game including the networking layer in Unity so I’ll write about both the Old System and the New System.

I’m also sharing a link to an early version of the New System, called “CaptainsMess“, as a Unity asset package. It’s not finished yet but Wifi connections work well enough for me to finish the rest of the game.

Please check it out and help me test and improve it!

CaptainsMess on GitHub: https://github.com/hengineer/CaptainsMess

The Old System (Spaceteam versions up to 1.8.x)

I wrote the original game for iOS using Objective-C and the Cocos2d game engine. It was later ported to Android by a company called Apportable. They have a cross-compiling SDK that generates Android apps from Objective-C code so there is no easily-accessible “Android source” to share. Apportable did make some of their Bluetooth code available though, which you can find here: https://github.com/apportable/Bluetooth

On iOS I used Bonjour (also known as ZeroConf) to discover other devices, which works over Wifi and Bluetooth. I wanted to make it as easy as possible to connect (users shouldn’t need to know or care *how* the game is connecting, they just want to play together!)

I learned a lot from the BeamIt! source code and also the “WiTap” sample code from Apple.

On iOS I used the NSNetServices API but I also used a third-party library called HHServices for additional Bluetooth support. I know that Zeroconf is an open protocol so I’m guessing there are probably implementations for Android.

When you choose “Play” the devices all start off as a clients and look for an available server. If they find one they try to connect to it. If they can’t find one within 3 seconds, they start advertising themselves as a server as well. When one of the connections completes successfully (client or server) the other one is cancelled. Eventually everyone gets connected. Sometimes this leads to more than one group (eg. 2 groups of 2, instead of one group of 4), but in practice this is pretty easy to fix by some players leaving and re-joining one at a time,

Once the devices are connected I use another third-party library called CocoaAsyncSocket to send messages and exchange data between phones. Again, I’m sure there are similar libraries for Android.

Other notes:

  • Bluetooth can only support 7 connections at most (I think this is a hardware limitation).
  • iOS and Android cannot connect over Bluetooth, I believe due to system-level restrictions. I’ve personally never encountered a mobile game or app that connects iOS to Android over Bluetooth. If you know a way to do this please let me know!
  • I broadcast a specific ID that represents the type of game being played, eg. “spaceteam_W_M” means that it’s a Wifi game with Massive mode turned on. That way players can only connect with other compatible games.
  • On Android when Bluetooth mode is turned on the server and client modes interfere with each other, so instead of having just the “Play” option I had to add “Host” and “Join” so the players must choose which mode they are using. It doesn’t switch between client and server automatically like on iOS.
  • Some Android devices/OS versions just don’t support DNS multicast over Bluetooth so I disable the Bluetooth option for those devices (the switch just says “Bluetooth not supported”).
  • Some Wifi routers don’t support “multicast protocols” or have “isolation mode” turned on, which lets devices connect to the internet but not to each other (the exact terminology may be different). There’s really nothing I can do about this, other than to suggest that people check their router settings to see if this mode can be changed…
  • On iOS I support devices running iOS 5.1.1 and higher but I’ve recently been having problems connecting iOS 8 to older OS versions so I may have to stop supporting iOS 5 and iOS 6.
  • On Android we support system version 2.3 and higher but on older devices even the Wifi can be unreliable (and I display a message warning about this and encouraging the user to upgrade if possible).

The New System (Spaceteam 2.0+)

I’m trying to replicate this system in Unity using as much out-of-the-box support as I can. My first attempt uses the Unity Networking HLAPI (High-Level API) introduced in Unity 5.1, specifically the NetworkLobbyManager and NetworkDiscovery classes. Unity’s source code for the HLAPI has been a great reference and is available here: https://bitbucket.org/Unity-Technologies/networking

I have my own subclass of NetworkLobbyManager and two NetworkDiscovery objects: one to broadcast and one to search.

When you choose “Play” the discovery server starts broadcasting its information and the discovery client starts searching.

The broadcast data holds information about the server, eg:

(version) : (unique peer id) : (is the server open?) : (number of players)

When this information changes, the server has to be restarted with new broadcast data and is treated as a “new” server, so the clients get another chance to decide whether to join it.

If the client finds an open server with at least 1 other player, it tries to join.

Otherwise, if nothing appropriate is found after 3 seconds, but there are enough solitary broadcasters to create a lobby then a decision is made for one of them to start a new (open) server. It’s important that the candidate is chosen unambiguously or they would split into multiple lobbies with one occupant each.

Currently the server candidate is picked naively using the lowest peer ID but this could easily be changed to favour the “best” device by comparing processor speed or something. Seems like a good idea but I’m not sure if it really matters yet.

Once players are connected to a lobby, the library then manages ready states and a countdown timer before sending a message to start the game.

So far only Wifi is supported but I’m planning to add Bluetooth support by integrating one or more 3rd-party Bluetooth libraries such as:

If you’ve used these libraries before I’d love to hear your experiences with them.

I may have to drop down to the Low-Level Network API in order to integrate them properly.

Some issues I ran into during development:

  • The broadcast data can’t be updated while the discovery server is running, so I have to restart the server every time I want to change the info. There is a bug in the Issue Tracker about this marked as Fixed but it still doesn’t work for me.
  • If I change the length of the broadcast data when I change the information (eg. using the strings “True” and “False”, which are different lengths, instead of 0 and 1) I got some weird buffer corruption. I’m going to investigate further, but just a warning in case you play with that.
  • I’m just using a single scene for Lobby/Game/Offline/Online even though Unity supports different settings for all these states. Depending on which of these values are set, I got behaviour ranging from SyncVars not working to my NetworkDiscovery objects being destroyed. Watch out for these things if you use different scenes.

Anyway here’s the link to the first public version. Feedback and improvements are welcomed and encouraged!

CaptainsMess on GitHub: https://github.com/hengineer/CaptainsMess

Space out!