Delta Engine Blog

AI, Robotics, multiplatform game development and Strict programming language

Increasing performance on the iPhone

After finding our game not running as fast as we expected, I dedicated the last 3 days of work on finding ways to increasing the performance.

There are 2 issues which have a heavy impact on the framerate. Drawcalls and Physics.
Both have several roots and solutions.

For the graphics part you should decrease the drawcalls as much as you can. Since every object has its own drawcall it doesn't take too long to have several hundreds of themm, which is by far too much. What you want to do now is combining them. Basically telling Unity to draw them as one object. This only works for objects that share the same material, so you might consider using the same texture with some fancy UV layouts for several objects. You start by creating an empty gameobject and assigning the desired objects as its child. Next you need the CombineChildren script, which is found in the Standard Assets.unityPackage and assign it to the gameobject you created earlier. Tadaa, all those objects will be drawn in a single drawcall now.
If you're working on a 2d game you also might consider using the SpriteManager class, which is a convenient way to draw lots of sprites in a single call. It supports UV-Animation, Billboarding and other goodies you might enjoy.
You can optimise your lightning by creating lightmaps for your meshes in your 3d composing tool instead of using dynamic lights, since Unity has no baking function.
Another rather unlikely scenario is a too high polycount. But remember just in case: it's an iPhone, it has a tiny display, you won't even see that much of a difference between 500 and 2000 poly characters, and even if, it's still just a phone. :)
That said you should be fairly well if you stay within this stats:
Drawcalls < 30
Polycount < 10k

As for the physics, if you're using a lot of physical objects, you should consider using the simplest collider you can (e.g. enabling Convex mode on MeshColliders, using SphereCollider instead of BoxColliders)
If this doesn't help, you have the possibility to decrease the precision, or increase the collision checking interval. Head to the Menubar>ProjectSettings>Time and increase the Fixed Timestep. Remember that decreasing the physics precision can lead to penetrating objects, objects getting stuck in each other, and other graphical impacts, so you should thoroughly test which works best for you. If you still want to get more out of it you can consider slowing down your gameplay. While doing this you can increase the Fixed Timestep even further.

Fixed Timestep Defaultvalue: 0.02

That sums it up. You can find more detailed explanations and help in the Unity Forums and the irc channel #unity on

Happy coding