Game Development

Updated at 2015-03-11 00:39

This note is about game performance and improving frame rate of games.

Always use a profiler. Optimizing your game will be a lot simpler if you utilize a profiler to see where the bottlenecks are and if your changes really change the things you are focusing.


  • Keep your triangles, vertices and draw calls as low as possible. Reduce draw calls using texture atlases. Bake lightning to objects.

  • Cache components: Directly get the component you want: BAD: GameObject -> Rigidbody. GOOD: Rigidbody and save to a cache.

  • Cache positions: Every time you access anything in transform, it has to calculate the position based on the location of its parent objects.

  • Static batching: Have as few different materials as possible Use the same material. Static Batching requires you to set the flag "Static" in the Object Properties panel. It can only be used on objects that do not move, rotate or scale in the scene.

  • Dynamic batching: Use objects with as little vertices as possible. Use the same material and mesh. Meshes must have less than 900 vertex attributes in total. Same objects with different scale don't batch. Lightmapped objects won't be batched. Multi-pass shaders will break batching. Using instances of a prefab are using the same mesh and material If an object has an animation but there are parts that never move, you can mark that part as static and it will not interfere with the animation.

  • Audio optimization: Note that only one hardware audio stream can be decompressed at a time. Using the “Decompress On Load” setting will fix this on mobile devices, but memory usage will raise.

      Short Clips = native
      Longer (or looping) clips = compressed in memory
      Music = stream from disc
      Files which consistently cause CPU spikes = decompress on load

Mobile and Tablet Games

Mobile and tablet games should run 30 FPS at all times, fast-paced games require 60 FPS.

  • Mobile 2015, shaders and lightning are the bottleneck.
  • Mobile 2014: Lights are expensive.
  • Mobile 2014: Draw calls can be expensive on some devices, keep it under 120.
  • Mobile 2014: Avoid painting pixels multiple times in a single frame.
  • Mobile 2014: 30 000 triangles per frame is the soft limit.
  • Unity 2014: downsize on poor devices with Screen.SetResolution().
  • iPhone 3: Keep it under 20 draw calls and 10k vertices.
  • iPhone 3: Keep it at 25-30 draw calls.
  • Samsung Galaxy 3 Mini: 200 draw calls works fine.
  • iPad 2011: 100 - 200 draw calls.

PC Games

PC games should run at 60 FPS at all times.

  • Assasin's Creed Unity: peaks at 50 000 draw calls.
  • PC 2013: 600 000 draw calls is way too much.
  • PC 2011: Over 2000 draw calls is not that rare.
  • PC 2010: 2000 draw calls is a bit excessive.