Simple Things to Optimize Your Unity Game

During the development of one of our recent games, Parkour Sprinter, there were a few simple things we had done to increase the performance of our Android port.

Here are a few of them.

Use mobile shaders

When you are using many shaders (and especially complex ones), they can take up a lot of performance when you shift your game to mobile.

This can be solved by switching the type of shaders to a mobile variant as can be seen below:

Doing this for your shaders will make them more friendly for your mobile devices.

Static batching

Did you know you could increase the performance of all of your stationary objects through just a simple check mark?

It may be easy to miss, but marking your objects as ‘Static’ can immensely give your game a performance boost depending on the number of such objects that exist.

Clean up the update method

The update method can become overcrowded with unnecessary calls.

For example, in your mobile port, you can avoid unnecessary checking of PC keyboard inputs or for mouse click events (especially if there are multiple such checks each frame).

Use profiling on your Android device

Rather than profiling on the editor or on your desktop build, you can enable an option in the “Build Settings” (Ctrl + Shift + B) to automatically open the Profiler when your game is deployed to your device:

As you can see in our Tweet below, through this Profiler, it was easy to see where the lag spikes were coming from as well as where most of the processing power went.

Here, it can be seen that Physics and problems in the scripts led to major decreases in FPS at some points while the rendering was a consistent problem throughout.

Quick physics optimizations

Wherever you can, try to use ‘discrete’ collision detection rather than continuous in order to further decrease the workload on the CPU.

Other more complex methods

There are other methods of increasing your performance; however, they are not as simple to implement as the quick fixes above. Nonetheless, if your game’s performance is still an issue, you should definitely research and implement them:

  • Object pooling
  • Multi-threading
  • Coroutines
  • Level of detail
  • Decreasing the meshes in your mesh collliders
  • Occlusion culling

These were some of the simplest optimizations that we had done in our projects. There are numerous more, along with the most important optimization tip: continuously incorporate it into your development process.

Any other optimizations we left out? Please do comment below.

Until the next post,

The Trollgen Team

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s