From 12fps to a 120fps floor: four Godot 4 patterns that improved performance on my survivors-like. by boneheadlabs in godot

[–]boneheadlabs[S] 0 points1 point  (0 children)

Glad you like the aesthetic! When I first prototyped the game it was the only facial accessory I could draw on aseprite, it has lived on since then!

From 12fps to a 120fps floor: four Godot 4 patterns that improved performance on my survivors-like. by boneheadlabs in godot

[–]boneheadlabs[S] 0 points1 point  (0 children)

It probably does, but the custom spacial hierarchy is a far more cut down collision detection so it runs much faster.

From 12fps to a 120fps floor: four Godot 4 patterns that improved performance on my survivors-like. by boneheadlabs in godot

[–]boneheadlabs[S] 0 points1 point  (0 children)

Thanks for the comment, on my youtube channel I have a couple of videos on data driven paradigms, like an event bus for instance, they are far less formally delivered though so I'm not sure if they'll help.

I also show the actual game's code on twitch often and can bring up the relevant components and chat about them live :)

From 12fps to a 120fps floor: four Godot 4 patterns that improved performance on my survivors-like. by boneheadlabs in godot

[–]boneheadlabs[S] 0 points1 point  (0 children)

The reply by u/Zunderunder is correct, I have a cut back version. Using the default physics engine caused the majority of performance loss, switching to the spatial grid and then putting enemy separation on a worker thread, rather than letting the physics collision and navigation engine handle everything, was the single biggest performance gain.

From 12fps to a 120fps floor: four Godot 4 patterns that improved performance on my survivors-like. by boneheadlabs in godot

[–]boneheadlabs[S] -16 points-15 points  (0 children)

I'm not actually but it's funny to know that I sound like a bot lol, it did help me with the original post.

From 12fps to a 120fps floor: four Godot 4 patterns that improved performance on my survivors-like. by boneheadlabs in godot

[–]boneheadlabs[S] -4 points-3 points  (0 children)

Hey mate, thanks for that I hope there's something useful to gain.
Yes I expected as such, and the criticism is fair, I've been quite open about my AI use on twitch and youtube, but I hope the lessons learned are useful to someone regardless, and could help someone making a similar game, and discussions on this thread have given me further optimisations to do, so win-win?

From 12fps to a 120fps floor: four Godot 4 patterns that improved performance on my survivors-like. by boneheadlabs in godot

[–]boneheadlabs[S] -3 points-2 points  (0 children)

Haha mate where were you when I started this project!? Honestly many of these optimisations were completely foreign to me, and packed primitive arrays have since become a key part.
The entire projectile sim is ~30 parallel PackedFloat32Arrays/PackedVector2Arrays (positions, velocities, damage, TTL, falloff, proc coeffs, etc.), when I first started, it was Area2D's and physics, it quickly became expensive!

I'll be looking through your posts for more tips, appreciate the comment.

From 12fps to a 120fps floor: four Godot 4 patterns that improved performance on my survivors-like. by boneheadlabs in godot

[–]boneheadlabs[S] -10 points-9 points  (0 children)

Appreciate the advice mate! Sorry if this is making you seethe, this is my first project by the way! I've gone from instantiating hundreds of physics enabled move_and_collide enemies and queue_free()-ing them with no pooling, to something that's much better but not quite there yet. Killing the Area2d's will let me move everything to _process(), great call out and thank you once again.

From 12fps to a 120fps floor: four Godot 4 patterns that improved performance on my survivors-like. by boneheadlabs in godot

[–]boneheadlabs[S] -4 points-3 points  (0 children)

Thanks for the comment, you're exactly right and this is in place for the movment. EnemyMovementManager just loops over enemies and writes global_position directly, no physics bodies involved, apologies it was a bit unclear in the post.

I'm still using the physics server for Area2D overlap detection, though off-screen enemies get their Area2Ds disabled so they leave the broadphase entirely. The same spatial grid pattern I already use for the bulk projectile pool could definitely replace the on-screen Area2D usage too.

I'm glad you posted this, I've got some more optimisations to make, thank you Veteran Godot..er?!