- Home /
Why my project takes me so much CPU capacity to run when playing?
Hey guys.
My game is a 2d platformer RPG, which combat system is mainly sword. In order to detect targets inside a certain space, a lot of Physics2D.Overlapxxxall are used.
As the title said, when I play my game in unity, unity takes more than 20% of my CPU capacity to run when there are multiple enemies in the scene. When I don't play my game, it just only takes less than 1%. My CPU is Intel i7-4770 3.40GHz.
Is overuse of overlapxxxall the reason for such thing happening? How can I fix it?
I appreciate your help.
I will provide my project copy later.
Answer by unityJe · Jul 07, 2019 at 04:23 PM
Have a look at your profiler. Window > Analysis > Profiler. Change the dropdown from Timeline to Hierarchy. Run the game for a bit, stop, click on the graph, and expand the trees. Post a screenshot here and we might be able to work out what kind of thing is draining CPU.
Also, make sure to delete any Debug.Logs that are repeating every frame.
Thank you so much for your advice, after deleting all Debug.Logs, the lags disappeared. Does it take a large cup usage to run Debug.log?
Your answer