I made a simple 2d game and build it to android platform. I profiled it and I saw it takes exceptional average CPU usage and also has high spikes. My game consists only in game screen:
and game over canvas that covers it when player loses:
I’ve added some images from profiler:
do you know which performance problems I might have?
1 Like
Please, expand “TimeUpdate.WaitFor…” and other stuff with high percentage.
I can see glowing of circle elements and many small parts of destroyed “[” object which can cause such issue.
Do you use any post-pocessing effects?
Thank you for your fast answer!
Actually, I tried to use Postprocessing but unsuccessfully, so I gave up…
Some more detailed images:
! - I see ObstaclesController.createObstacle takes ~20ms, but it only instantinates a prefab - is it possibe that object.instantinate will take so long? (the prefab consists of: 4 sprite Renderers, 2 RigidBody2D, 2BoxColliders, 1 CircleColliders, 2 particles effects and also some scripts)
1 Like
Definitely. You can use the Object Pool design pattern to solve it.
But before, I want to warn you against making optimizations until your game shows freezes, gameplay disruptions and so on. You can learn more here.
In Short: If your game runs smoothly on the target devices, don’t waste your time on optimizations. Of course, the architecture of the application needs to be thought out in advance. But if you already have an application that works seamlessly on target devices, then you know the answer.
1 Like