Simple way for mobile games using Unity to save battery power.

Posted by Pingu on Jan 6th, 2017 - Basic Other

Simple Battery-life and Energy Optimization for Mobile Games using Unity



Are you creating a new mobile game using the Unity engine and your mobile-phone is getting really hot after playing for a while? Have your players complained about the app is draining their batteries?

If you answer yes on one of the above questions or you are just interested in a simple way to optimize battery-life for Unity games, then this guide is for you.

Frame rate is the key

I had the same problem when I first started developing Labyrinth Robots. My friends that tested the first alpha version of the app told me "the app was sucking the life out of their mobile". So I understood that it was very important to do something about it.

The simplest and most effective thing I found was clamping the frame rate. I put the maximum frame rate to 60 fps (frames per second), which was enough to have smooth movement and animations while still not turning the phone into a heater. Then turning the fps down during parts where the game didn't need all the fps.

Since Labyrinth Robots is a casual problem solving game it contains parts where the screen will remain idle for a very long time while the player is thinking. This is perfect time to optimize and lower the fps to 15 fps during these times. There is simple no reason to let the game render a lot of frames if these frames will be the same anyway. This trick may not work for all game types, but it is very handy for casual games.

How to set frame rate in Unity

First of you need to change a setting found in Edit->Project Settings->Quality. Under the Other section you will find V sync Count. (Unity doc: Docs.unity3d.com)

V sync Count must be turned off.





Then you can set the maximum frame rate in code using Application.targetFrameRate. For example:

public class MyGameManagerClass : MonoBehaviour { void Awake() { Application.targetFrameRate = 60; } }

Using this technique I could drastically lower the battery consumption of Labyrinth Robots. I recommend testing with different frame rates to see what fits your game the most.

Hope this guide will help!