Posted on October 27, 2011 by Doolwind

Targeting 4 Platforms Simultaneously With Unity

We’ve just released Battle Group on four platforms simultaneously. Porting is usually a lengthy process that I hate to do. I quit my job in the mainstream video game industry partly over being forced into porting one of our latest games. Thankfully this is not the case when porting with Unity as the time required is measured in days rather than weeks or months. Today I’ll share my experiences porting Battle Group with Unity.

Overview

Our primary platform for Battle Group is iOS (iPhone, iPad and iPod Touch) while our primary development platform is PC. This took us approximately four months to complete and it took a further 10 days to port to Android, Pc and Mac. Our first two games were both iOS exclusive so this was our first time developing for the other three platforms as an indie team.

Input Changes (Mac and PC)

One of the biggest challenges was making the game work well with both touch and mouse input. Back when we created Flick Buddies I created a unified input system so that the mouse and touch are treated through the same code path. This went a long way to simplifying the process of targeting both input systems. The input basically boiled down to “On Down”, “On Move” and “On Up”. Unity’s “Touch” class is extremely helpful and saved us a lot of time. The only game specific challenge we faced was around ship selection. We made use of the scroll wheel and keyboard for extra player control, both of which only took an hour or so with Unity.

Overall we were really happy with the way the input worked across all platforms and we decided to keep them very similar.

Multiple Resolutions (PC, Mac and Android)

The area I’m least happy about with Battle Group is the multiple resolution support. While we support any resolution and aspect ratio, the fact we targeted iPad primarily (1024×768) meant the game isn’t really wide screen. We decided to fully support any aspect ratio between iPad and iPhone and add letterboxing to resolutions outside this. For gameplay reasons we could not allow an unlimited amount of aspect ratios without letterboxing. The biggest concern for me is that letterboxing usually runs along the top and bottom of the view and people expect this. In Battle Group, as we targeted iPad primarily, our letterboxing runs along the left and right handside for extremely widescreen aspect ratios.

The actual implementation of multiple resolutions was fairly straightforward with Unity. As Battle Group is a 2D game we were using an orthographic camera and I simply adjusted the size of the camera’s view area to accommodate different resolutions. The biggest complexity involved created the settings page allowing players to choose the resolution and full screen. Unity has amazing support for resolution changing, including full screen and windows. I have horrid memories in DirectX of lost context and all sorts of issues that are gracefully handled for us now.

One small point of concern is multiple monitor support. Out of the box, Unity doesn’t support locking the mouse cursor to the primary screen. There are some platform specific workarounds but nothing I was happy with and so for version 1 we don’t lock the mouse cursor. This is a personal pet hate of mine and so I was quite disappointed however timeframes didn’t allow me to obsess to long on this feature.

Demo Version (PC)

The PC version we sell through our website has a demo that unlocks with a CD key. I spent a while looking for example code for CD keys but couldn’t find any I was happy with. Instead I spent a few hours and threw together my own CD key generation and checks and it’s worked quite well. I used Unity’s built in text box for the CD key input and this actually worked quite well. Players can cut and paste the CD key from anywhere and I then do some quick validation. I always warn my students not to use the built in Unity GUI, however in this case it worked really well.

Mac App Store

We decided to release a Mac version on their Mac App Store to coincide with the iOS release. Having already ported to PC this was an extremely simple process until the very end. Unfortunately there’s a little monkey work that needs to be completed in the final step that Unity does not currently handle. Check out the following links for detailed instructions on how to complete this:

One key point is that you need to make sure “Player Log” is turned OFF. We failed certification the first time as we were still writing out our log file.

The Mac version of Battle Group is actually our best seller at the moment. We were featured in “New & Noteworthy” and we are currently the #4 game in Australia and #12 game in the US. This was a great surprise and we were really happy we took the time to port to the Mac App Store.

Android

After initial issues setting up the ADB driver for my Android device this was another smooth process. The Android shares nearly all the code of its iOS sibling and the only major difference was supporting multiple resolutions and aspect ratios for all the different Android devices. I had already completed the resolution code for the PC version and therefore this all “just worked”.

Post release, we had a small hiccup with “1 star spam” where someone (probably a competitor) spammed our game with 40 1 star ratings in under 30 minutes. Thankfully Google were quick to rectify this, however it was not a great feeling.

Performance

I spent a week or so heavily optimizing the game and rendering for Battle Group about three quarters of the way through development. Per platform optimizations weren’t really necessary and we’re happy with the frame rate on all platforms. There were really only two limitations I put on our game designer as he created levels, both of which were increased at his request a number of times. These were mainly around the number of concurrent enemies on screen at one time as both the game logic and rendering increased linearly with this number. The only major outstanding concern I didn’t get enough time to look into was load times on some slower devices. For some reason Android particularly takes a lot longer to load than its iOS counterpart and this is something I am planning to fix in a future patch.

Closing Thoughts

Overall I was overjoyed with how well the porting process went. I consider it one of my least favourite parts of video game development and the fact it went so quickly and smoothly was excellent. I always listed cross platform support as one of Unity’s biggest drawcards and now I can confirm this. Not just that, but the simplicity of this cross platform development is a real plus. For a small studio, spending months porting to new platforms simply isn’t an option for us and this has allowed us to hit all the platforms we wanted on the same day.

Instead of spending time porting we can now work on updates to Battle Group and future games that we have begun prototyping.