Jump to content
  • Advertisement
  • entries
  • comments
  • views

Rocket Rascal Optimizations

Sign in to follow this  


My latest game, Rocket Rascal, was just released into the iOS and Android app stores.

(You can get it here for iOS and here for Android)

I wanted to write a little bit about how I got the performance of this game to an acceptable level.

For being such a casual game, I hit some serious performance issues late in the game. The iPhone 5 ran pretty much flawlessly, but the iPad 3 ran at 30-35 FPS, and the iPod Touch 4th Gen ran at 12-17 FPS. The 4th Gen was my low mark, and I wanted to get that up to at least 30 and the iPad 3 to at least 45.

Problem 1: Garbage
If you develop in Unity for mobile, the garbage collector is going to crop up in your profiler at some point. The general rule: never generate garbage per-frame.

This is harder than it sounds, since seemingly innocuous calls generate garbage. Things like gameObject.name generate garbage, and gameObject.GetComponent generates garbage only if the component doesn't exist. Converting numbers to text can also be obnoxious, especially if you have something like a "Score" string that changes frequently.

This was mostly low-hanging fruit though - the Unity profiler made the problem points easy to identify and address.

Problem 2: Fillrate
Have a look at the cityscape for the game:

There were 3 large images (*large* images) that were very fill-rate heavy. The resolution of iPad 3 is 2048 x 1536, and stacking these gets really expensive. I couldn't cut these out, they were critical to the aesthetic of the game, but they were definitely dragging me down.

The solution here was to cut all those images up into two sections: the bottom portion didn't have alpha at all, whereas the top (smaller) portion still needed the alpha. Then I wrote dirt simple shaders to render this. Making the bottom portions opaque allowed them to be rendered much faste.

This had the most pronounced impact on performance, and I quickly saw a 15 FPS boost on iPad 3.

Problem 3: Colliders
Unity doesn't like having colliders manually moved around. It gets fussy, and performance starts to drag. The game uses almost exclusively hand-controlled colliders, however, so I had to do something there.

I got a decent bump by just not updating the colliders of entities that weren't visible. It wasn't huge, but I couldn't exactly overhaul the game to address this.

Problem 4: Sandworms
There are 3 sandworms that are constantly chasing the player, and sometimes there are extras in the background for aesthetics:

The sandworms were created by tweening the control points of a spline and then dynamically generating a mesh from that. Two subproblems arose from this: dynamically generating the mesh was expensive, and updating the collider was killer.

Optimizing the mesh generation required just rolling up my sleeves and hammering on problem points the profiler picked up. There was only so much I could do here. I made a few loops take up less time and simplified how the curve was extruded, but ultimately didn't gain much.

Optimizing the collider yielded significant boosts. Initially I was using a mesh collider for the snake, which was brutally expensive. Instead, I switched to approximating the shape with multiple capsule colliders. I also switched to only updating those colliders when the snakes were visible.

Problem 5: Device Hangups
The 4th Gen iPod just isn't that good a machine. There was an upper bar that I was never going to exceed.

I turned off several features for the low-end devices. Motion blur had to go, and some of the background VFX get turned off dynamically.

Dumb Luck
I reached a peak on the iPad 3 of between 45 & 55 FPS, leaning toward the low end. Then I updated Unity to the latest release and the average became closer to 55-60. So... that was nice.

There were a bunch of other tiny things that needed tweaking, but the above had the most significant impact on performance. I managed to hit my iPad 3 target. 4th Gen iPod fell a little below the mark - it averages closer to 25 FPS, whereas I wanted 30, but I can live with that.

It was definitely a *long* week of banging my head against a wall, so I'm very glad I was able to hit my performance targets.

Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!