Game running slowly

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Jackson King

I have had this problem with my game that causes it to run slowly. It runs at about 8–9 FPS which I think is rather slow for a 2D platformer. I have pinned it down the problem to the enemies (because if I remove all of them my FPS jumps to 60).

Knowing that the problem was directly or indirectly related to the enemies I tried removing all of their code. This did nothing, however, as did removing the player’s code. I tried removing the enemies and adding back the enemies one by one and found that no particular type of enemy was causing the problem.

As I mentioned above, the only thing that completely fixed the problem was removing all of the enemies, although removing the enemies one by one improves the problem gradually.

Through this I was able to deduce that my problem might be caused by too many entities? However, I only have 12 enemies so this shouldn’t be my problem. I haven’t been able to find a solution to my problem anywhere else and was wondering what could be causing it and how I could potentially fix it.

In 3D i’d guess on a mesh that is far too complex. Here in 2D, which assets are you using for sprites and textures? May it be that they’re far too big? (i.e. 2k x 2k pixel for a sprite that is 64x64pixels on screen?)

But as Dooowy mentioned maybe it is some bad code in _process() or _physics_process() use Godots profiler to see what code is using how much.

wombatstampede | 2019-06-20 14:09

:bust_in_silhouette: Reply From: Dooowy.

There is not enough information. However, It could be scripts. Do you have a script in _Process that will always run when _Process() is called? Staggering _Process’s scripts may solve the issue. For lightning fast Frames, you should consider using C#.