Mysterious slowdown with high health enemies

I am totally stumped here.

So, the game I’m working on has a lot of bullets and a lot of enemies everywhere. It works like magic (144 FPS) and is perfectly optimized with lower health enemies.

When enemies with higher health show up, suddenly it stats chugging. There are things like multiple ticks per bullet, status effects being applied, calculations, etc., but they don’t have this issue with lower health enemies that get killed in 2-3 health. When the enemies take maybe like 10-20 shots to take down, it starts chugging.

I’ve added extended variable support to clear memory, done everything including Trigger Once conditions to make sure that the ticks aren’t happening too much.

I’m basically totally stumped. It’s got nothing to do with memory leaks because even 20-30 minutes in, if I spawn in low health enemies, it goes from 30 fps back up to 144.

Anyone have any ideas what’s happening?

Use the profiler to figure out what events are causing the slowdown. My guess is that the enemies with higher health are probably affected by different events or using different sprites images, leading to the slowdown.

Make sure your images are under 500x500px resolution for best rendering performance!

That’s the weird bit. The profile says it’s running under 6-7 ms at most (which is very low). The game is super well optimized. My guess is that it’s triggering too many checks each time it hits an enemy. You also could be right about the size of the enemies, but they’re like 120 pixels tall vs. 70 for lower health enemies. Will report back once I figure this out.

Hmmm… Are you using effects when those enemies are present? These can be heavy on the GPU and if the GPU lags behind, this will create extra lag that GDevelop cannot always measure.

Particle effects that create a single image. But I guess it’s happening like 50 times in a half second. Would that slow it down?

I managed to get it to stop chugging, it still microstutters but is at least playable now. It’s not great but not as terrible but still not ideal.

The issue was Trigger Once placement. Adjusting it slightly on subevents makes a huge difference. Can’t be 100% sure though. It’s finnicky. Trigger once is your friend, peepz.

1 Like

IDK how much it would help you but

I have game where i have buildings
And if building gets any damage so its HP is even 1 below Max HP
It displays (create) HP bar for that building
And so my game started to drop FPS after idk 1 or 2 mins
I was unsure why
Was it related to the HP bars? Or what?

Turned out when i distribute HP bars to buildings and i link them to buildoing
I SHOULD use INVERTD take into account buildings that have HP bar linked to them

This way it was linking HP bars ONLY to buildings which did not have YET any HP bar

Without this condition it was constantly creating HP bars to building and from that FPS drop came

So if you are creating something on the fly
Like particle emitter you need some means to limit what object and when is getting it
Because you maybe are just spam creating them left and right

Thanks. I have some minor indicators to display bosses, but they’re on Trigger Once. I thought about the “linked” condition causing slowdown but I doubt it. It’s worth looking into.

I would say anything that CAN help you reduce lag is worth looking into

Yeah. It’s friggin’ bizarre how it just only happens on high health enemies. I would think maybe they’re retaining some variable that causes it to slow down but I’ve been super careful.

Okay, so I spawned the same exact enemies at the very beginning of the level and ran it for about 5 minutes with a huge amount of enemies and bullets and it still runs at 130 FPS, smooth as butter.

So my guess is that there’s some kind of memory leak happening after roughly 10-15 minutes of gameplay and it’s not related to enemy HP.

1 Like

Does anyone know why an FPS counter may not feel accurate?

I can get the game to never really run under 80-120 FPS, but it still feels like it’s got microstutters and slight lag-like slowdown.

Does this have to do with my PC’s specs? My computer is notoriously bad at optimizing for games to run smoothly (It’s an ASUS Tuf Gaming laptop).