hi everyone!
i make an android game in unity, and I have lots of lag in my game while testing in my phone.How do I fix this?
how i can fix lag in my android game?
There is no for sure way to fix the lag because it differs from one game to another. Here are a few suggestions
- Try baking your lighting data onto your your assets so that it doesn’t have to be calculated every single frame at run Time. There re many videos on Youtube that can assist you with that
- Try using static batching by marking your assets in the scene as static for batching. Again there are many tutorials for that on Youtube
- Also try enableing GPU Instancing on the materials of your assets( its a checkbox on the material once you have selected the material, everything about the material will appear in the inspector, including GPU Instancing)
- Try using an occlusion system in your game if it is necessary, I mean what the camera doesn’t see shouldn’t be rendered and that is what the occlusion system does(disables gamesObjects that aren’t been seen by the camera)
- If your using a terrain be sure to tick the checkbox of GPU Instancing on the settings of the terrain(the terrain’s own settings that will be visible in the inspector once you have clicked or selected the terrain either in the scene or hierarchy view)
- Try using a LOD system for all your gameObjects in the scene. There are lots of videos on Youtube that can assist with that
- Check your scripts an ensure that you never left a “Debug.Log” or “print” message on any f the scripts because these statements can cause your game frame rate to greatly drop
- If you seriously want to get the best performance as far as you scripts are concerned, consider writing your scripts using unity DOTS, meaning writing coding as ECS representation. There are videos on Youtube that can assist you with that
- The ultimate way to really optimize your game is to use unity’s Profiler in order to find out what is causing your game to lag in the first place, and finding the problem basically means that your half way done with solving the problem. So that you can know where to direct your attention to when optimizing your game. There are many video tutorial which can help you with that on Youtube