"Trigger once" with "Repeat for each instance": different result than expected

Hello, people :slightly_smiling_face:

I have been using Gdevelop for just over 3 months and I don’t know to much about the game engine. But I learned something in that time that is probably one of the few contributions I can give here on the forum. I explains to other beginners that using Trigger once with Repeat for each instance may be being the big problem with their code when they are dealing with multiple instances of the same object. And from what I have noticed during this period has appeared a considerable number of people with this doubt.

They use “Trigger once” with “Repeat for each instance” believing that it will occur one time for each instance, but that is not what happens. The condition occurs only once in a single instance and not in the others instances while the condition is true. I’m not saying it’s wrong but apparently it’s not what many of us expected. We expected that happens once for each instance. I took a few days dealing with my project to understand what was going on and fix the code by removing the trigger once from all events with “repeat for each instance” and “limiting” the events to occur only once using others conditions.

My suggestion is to have some kind of flashy and explanatory warning to prevent users from using “trigger once” with “repeat for each instance” without knowing what will really happen. I do not suggest a change in the effect of the “trigger once” with “repeat with each instance” because I couldn’t even think how complicated that change can be and yours impacts (and maybe someone want to use like it works right now). Also “limit” the “Repeat with each instance” to occurs just one time per instance isn’t a hard thing.

3 Likes

Good call out. Happily, I can say this is currently in progress.

4 Likes

As someone who has ran into this inconsistency before I completely agree Rasterisko!

@Silver-Streak

This Extension is Legendary. It helps so much with lots of instances on screen that you need to repeat a certain variable randomly. Thank you for sharing this really helped my game.