I’m working on a wave-based game, but I’ve run into a game-breaking bug.
At a certain point, one of the enemies simply won’t die. Because of this, the wave doesn’t finish, and the entire game glitches out to the point where you can’t do anything or progress any further.
Could this be caused by an issue with event execution order, collision/health checks not triggering properly, or object variables not resetting between waves?
Any ideas on what might be causing this or how to debug it would be really helpful!
Probably it’s one of those “Trigger once” inside a “Repeat for each” problems.
When you add a “Trigger once” condition inside a “Repeat for each”, the event isn’t triggered once for each instance; it only triggers for the first available instance (i mean.. if the anim dead doesn’t start the instance can’t be deleted in your case). I would check there first. If that’s the issue, try using a variable instead…
As @RMDB wrote, the issue will be the trigger once. If two objects meet that condition, only the first will be actioned, and never the second as the condition will continually be met.
A trigger once condition is reset if the event’s conditions are no longer true for a few game frames.
You don’t need to repeat for each object in order to test it. Conditions will select a group of objects that meet the criteria (they become in scope), and GDevelop will use all of the objects in scope in the actions and any subevents.
To fix, drag those 3 events under the repeat so they’re all level with the repeat event and then delete the repeat event. Modify the last of those 3 events, so the conditions look like below (there’s no need for a trigger once, as the animation change will prevent the enemy from being selected again).
Note, I’ve omitted most of the actions and included the actions that impact the conditions. You’ll need to keep the actions in your events.