Some Initial Impressions of Using Unity iPhone
For a while now I’ve wanted to develop a version of my Old Testament adventure game for the iPhone / iPod Touch using the Unity game engine. But it requires so much initial upfront investment that I’ve been endlessly putting off the decision, particularly since I had no idea exactly what an iPhone was really capable of – would it be able to handle a bunch of animated 3D characters without grinding to a halt? Well, in the end I took the plunge, and here are my findings!
The True Cost of Unity iPhone
Firstly, though, let’s just sum up exactly what an upfront investment we’re really talking about here. It turned out to be rather more expensive than I’d anticipated!
- Unity iPhone Basic License: $399 – this cost is pretty transparent, no surprises here.
- Mac Mini: $599 – in case it wasn’t clear, Unity iPhone requires a Mac development environment, since you need to be able to run Xcode from the Apple SDK. If you’ve already got one you can obviously discount this cost. The cheapest piece of Apple kit is probably the Mac Mini starting at $599, I personally got a discount on a 13″ Macbook coming out at about $800.
- iPod Touch: $199 – I’d hoped I could do all my development in the Unity development environment and then borrow my housemate’s iPhone to do some occasional performance testing, but it turns out that a physical iPhone/iPod touch is essential for your ongoing development: all interaction takes place using an actual device which then sends signals back to your dev environment. For performance reasons you may be best off buying a second-hand 1st generation iTouch from eBay or something – mine set me back about $100.
- Apple iPhone Developer Program: $99 per year – again, because of the way you need a physical device for development purposes, you can’t leave signing up for the Apple dev program until the end. You have to pay the annual fee before you can even get started using Unity in earnest.
Total cost: $1,398 (minimum $498 if you already have a Mac and an iPhone).
The Software Itself
The first big surprise for me when firing up Unity iPhone was the extent to which it is an entirely separate product from the normal Unity. This may be a versioning thing – I’ve only ever seen the latest version of Unity – and the iPhone version may just be a version or two behind, perhaps. For now, at least, many of the interface elements are quite different if you’re used to the standard Unity. For example, the widgets for rotating game objects work differently – not necessarily worse, just differently. The whole thing just looks a lot blockier and more old-fashioned, for some reason.
Secondly, as I’ve already hinted at in the costs section, the workflow isn’t entirely what I’d expected. There’s a great little summary of this on GameDev, but here’s a brief outline:
- Rather than running an iPhone emulator on your Mac, you actually run a Unity emulator on your iPhone!
- All the code is then executed on your Mac during development, and Unity just streams low-quality images to your physical device. Touches / tilt readings are then fed from the device back to Unity. This means that (apart from GUI interaction) mouse clicks on your Mac are ignored – you really need a physical device if you’re to test any kind of interaction with the user.
- When you’re happy with your code, Unity builds an Xcode project which can then be compiled like any other iPhone app and downloaded to your device for testing. This can be done in a single click from within Unity, but takes a few minutes to happen.
In case you missed the small print, there are a number of important pieces of .NET (C#) functionality that are not available in Unity iPhone:
- Anything that uses System.dll or System.Xml.dll. This includes reflection, but also things like System.Collections.Specialized – you’ll have to stop using HybridDictionaries and things like that.
- Anything from .NET 2.0, like generics
(Update: Unity 1.6 was released today that actually fixes all of that – you can now use .NET 2.1 functionality and System.dll)
Unity iPhone also has no support for programming in Boo, for reasons that I’m not sure of.
For me, at least, the million dollar question was regarding the hardware capabilities of the iPod Touch/iPhone – especially the first generation ones. The iPhone 3GS is a seriously powerful computer, but if you make your game so that it only runs on the latest hardware then you’re ruling out a large proportion of your potential audience. I deliberately bought myself a first generation iPod Touch off eBay – apparently the first generation iPhone has very similar specs in terms of CPU speed.
I have to say, my expectations were not very high when I finally got to the point of being able to test. Since I’m developing an adventure game, I need to be able to have a good number of animated characters on screen at the same time, and I’d feared that the iTouch just wouldn’t cope, particularly by the time you’d added in a few particle effects and background scenery.
But I was totally wrong – these devices are remarkably capable, and the guys from Unity have clearly done a great job of optimising their software to squeeze out every last drop of speed.
For testing purposes I used a character model with 738 vertices and 692 faces. The armature featured about 30 bones, and here you can see the frame rates I was getting as I added more and more of these characters on screen, all running the same animation but out of sync (just in case Unity tries to do any clever optimisations for characters at the same frame of the same animation):
||Frames Per Second
Even with 15 characters, running just above 8 FPS, it didn’t look so jerky as to be unplayable – at least not for an adventure game like mine. Exactly what framerate you need probably depends on how important fast responses are to your game.
The scene below with 5 characters, a relatively simple environment mesh and a particle simulation ran quite happily at about 22 FPS.
All told I’m immensely positive about what Unity iPhone is capable of, and have high hopes for what I’m going to be able to achieve with it. The engine is a real joy to work with, and the capabilities of the hardware far exceed what I’d expected from it. The Unity community is incredible, and help is always available when you need it.
If you’re thinking about taking the plunge, I hope you’ve found this article helpful. Feel free to Twitter me if you want to ask any further questions, or check out the UnityAnswers website.