0
\$\begingroup\$

I am using Godot as my game engine and I am making a basic 2D game, I have a small map with 1 Player and 5 Enemies walking around in it. The game includes some basic code for walking and shooting at enemies, so nothing too crazy. However, the game uses up to 18% of my cpu (I have an Intel Core i7 920) which it usually only does when playing big 3D games. So, what am doing wrong? I think I might be keeping track of to many enemies? I already tried the Low CPU usage option in the Godot settings, but it didnt really change anything.

Here's what I found in the profiler:

I was running for 1264 frames and it gave me this:

Script Functions - 22.79 ms

_physics_process - 80.89 ms

_physics_process - 32.96 ms

_on_Area2D_body_entered - 16.00 ms

check_input (A function checking key input) - 14.37 ms

shoot (Instancing a bullet scene and moving it) - 10.11 ms

\$\endgroup\$
8
  • 2
    \$\begingroup\$ Aren't there profilers for Godot? \$\endgroup\$
    – Vaillancourt
    Jan 8 at 21:24
  • \$\begingroup\$ Sorry, I just learned about it. Yes it has one, I dont really understand it but I will attach a screenshot of the data to the post \$\endgroup\$
    – pion
    Jan 8 at 21:47
  • \$\begingroup\$ Welcome to GDSE. There's any number of things that might be impacting performance. Making guesses (even with the help of the internet) isn't going to be nearly as productive as using tools to find the actual problem. The official documentation has information regarding tools & optimizations including a link to info about improving 2D performance. \$\endgroup\$
    – Pikalek
    Jan 8 at 21:49
  • \$\begingroup\$ Thankyou, I will take a look at it. \$\endgroup\$
    – pion
    Jan 8 at 21:51
  • \$\begingroup\$ Also, you might want to compare performance to a basic "hello world" Godot project. Sometimes there's a minimum of resources that a framework uses. I doubt that's the only thing going on here, but again, without some measurements & comparisons, it's relatively impossible to get a sense of what's going on. Using one of the starter projects will give you a baseline for comparison. \$\endgroup\$
    – Pikalek
    Jan 8 at 21:54
0
\$\begingroup\$

I used a Tilemap as my Level and it was put in front of the player in the node tree, so the Level outside the player camera was rendering as well. It now works just fine

New contributor
pion is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .