Gaming performance is the one of most essential key of successful game because no one want to play laggy game or low performance game. Bad performance effect user experience in bad way which results loss of users to play your game and no users your game is null or in simple words it will be waste of time, money and efforts. So before developing game, you have to consider or keep in gaming performance in your mind because later on it will be difficult to handle gaming performance. So pro tip is you have check or test your game against performance during development. In this way you will handle all gaming performance issues very easily. In this article I will be sharing information or techniques related to improve your gaming performance drastically. I hope this article will resolve tension of performance issues in your game.

How to improve your gaming performance in unity 2020
How to improve your gaming performance in unity 2020

Lets start from very basic, your gaming performance depends upon two things that is

1. CPU
2. GPU

CPU is central processing unit while GPU is graphical processing unit. CPU is responsible your script (code), physics, collision and every backend process. The CPU send instructions to GPU to draw frame. So GPU is responsible for high quality graphics, polygon count and every frontend processes. Optimizing these two processing unit boost the performance to a next level.

CPU Optimizing Techniques

1. Script optimization

Try to use these function as less as possible because these function called every frame per second if you put more code inside these function can cause more CPU power usage ( CPU overhead ) and the end result is loss of gaming performance.

   a. Update()
   b. FixedUpdate()
   c. LateUpdate()

2. Draw Call Batching

Unity uses draw call function every time when unity any game object on screen and this draw call produce CPU overhead because it consume significant amount of CPU power. Unity provide draw call batching option for this issue. When you enable draw call batching option so it merge all game object to render on one call or merge few game object to render on one draw call thus reduce number of draw call to more than 70 percent before which drastically improve your gaming performance. Unity provide two techniques for batching draw call, both technique reduce draw call but their way of  reducing draw call is different.

  a. Static Batching
  b. Dynamic Batching

To know the difference and on which places static or dynamic batching is best to use, to know this answer check this out unity static vs dynamic batching.

3. Enable or disable gameobject

There are a lot of game objects in scene view which consume memory and most of game object is use less (not in working state). To utilize memory or rendering of objects efficiently you need to enable only those game object which is currently used and disable all other game object to optimize your gaming performance.

4. Object Pooling

Object Pooling is technique to save game object in list or array whenever you want it, you can use it from array or list (reuse). Why we need object pooling in our game and the answer is to avoid Instantiate() and destroy() method which create and destroy game object. Frequent use of these method cause memory spike and slow your gaming performance. To know more about object pooling you can see here Object pooling in unity.

5. Set up your audio correctly

Use wav file for small sounds like sound effect and use mp3 file for streamed files like background music, reason behind this is that wav music file is 3 time larger than mp3 file in size for example same audio of mp3 file is 3 MB then same audio file when converted into wav file will increase it size to 10 MB. If you don't care of audio setting or audio import, it can increase your game load time and make your game laggy to play. Here is all the details of correct audio setting and audio import.    

GPU Optimizing Techniques

1. Set your quality setting correctly

a. Set your default setting to medium.

b. Set Pixel light count to zero.

c. Disable realtime Reflection probes

d. Disable shadows if not needed.

2. Set TargetFrameRate to 60 FPS

Increasing FPS improve the gaming performance and enhance user experience, by default unity has 30 FPS for games but you can change it to 60 FPS by adding one simple line of code to your script.

private void Awake(){
Application.targetFrameRate = 60 ;

3. Occlusion Culling

Occlusion culling is feature provided by unity, by default unity render every thing which is in scene but enabling this feature can render only those game objects which is seen by main camera, remaining other game object will not render which reduce load on GPU and improve your gaming performance drastically. To view detail information about it click here Occlusion Culling details.

4. Culling and LODs

By default, in unity you can see all details of game object from any location (far and near). LOD is basically level of details and this is feature provided by unity by enabling it game object level of details ( resolution ) will reduce if player or character move far from that game object in simple words it will show different resolution of game object at different position of player to save GPU power and improve performance. To know all its details click here Culling and LOD's in unity.

5. Reduce Camera render distance

By default your main camera have some value for rendering game object within distance. In simple words if you reduce render distance of your camera ( clipping plane or field of view ) or set the render distance through camera.layerCullDistance api, below is the script to help you understand easily.

        Camera camera = GetComponent<Camera>();
        float[] distances = new float[32];
        distances[10] = 15;
        camera.layerCullDistances = distances;

Conclusion and Unity Profiler

Using these above techniques you can optimize your CPU and GPU which is responsible for your gaming performance and using optimizing technique you can improve or maintain your gaming performance in high level of games. There is one tool in unity which will monitor your gaming performance and tell you on which place your game performance drops by which factor and this tool is called unity profiler. Use unity profiler for improving your gaming performance in unity.

Previous Post Next Post