- Home /
Game starts slowing down
So, I am about to finish my top-down shooter game but after a while when the enemies start spawning really fast and start stacking up the game starts to slow down and stops even on my Note 20 Ultra which has one of the newest mobile processors. What optimizations can I do to make it constantly run at a constant 60 fps.
Answer by GDGames0302 · Jan 30, 2021 at 07:42 AM
Firstly, you can deactivate RaycastTarget for every UI that is not a button(text, image..). This way, the game will not check every frame if the player has clicked them. Secondly, if youre using static objects, you can activate occlusion culling on the camera and bake the static objects. Also, for static objects, you can use static batching. Also, instead of instantiating and destroying, you could use object-pooling, that means you can simply activate and deactivate objects, not instantiating and destroying them. From Player Settings, you can activate IncrementalGC which empties your garbage collector gradually, not all in one frame. Also, if your enemies are 3d, meaning they have a material , you can activate GPUInstancing, which means that the game renders an object multiple times, and when you need another one, it uses a copy of the renderer, it doesn't calculate it again. Also, you can compress every sprite and music for Android. You can use also baked lighting. Also, use cheaper colliders, like CapsuleCollider, CapsuleCollider2D, BoxCollider, BoxCollider2D, SphereCollider, CircleCollider2D, and not PolygonCollider2D or MeshCollider. You enemies don't need RigidBody for detecting collision(only for physics), you can have RigidBody to the bullets(since the enemies are stacking and the bullets are destroyed or deactivated when they hit something). Don't hesitate to ask if you have further questions.
Static objects are objects that don't move. But you need batching and occlusion culling only for 3D