I don't understand this


I have done the gdevelop platform tutorial and when the player collides with two or more coins at the same time then these coins are destroyed. However only one time the score is increased. Weird isn’t?

I mean in a collision we have two instances and the actions are for one of them, no for another instances. Am i wrong? Then why is so confusing?

I could understand that only one collision is detected in that frame and the score is increased one time. But in the next frame another collision would be detected and the score would be increased again.
I know using “for each object” is the solution but what i want is understand what is going on because i can’t code if i don’t know what is happening. Thank you guys.


I think this scenario is exactly what’s being discussed in this thread. Keep an eye on it to hopefully get an answer.


That thread no answer my question because in the same frame the trigger once event is executed one time and for the next iterations it is ignored. If the collision event would have that behaviour all the coins would be deleted, even the coins without collision. Because the collision would return true and the next iterations delete the coins in collision or no collision.

I think Mr.Men you are not wrong but I need an answer more accuracy for my case please


I’ve had to address in my own design to handle multiple collisions.
I’m not sure how the underlying code is generated so this may cause performance issues, but here’s how to address this.

Change your logical condition from:

Coin in collision with player

To a for each loop:

For each Coin do:
Coin in collision with player

My black box understanding of why this matters is that the first condition “selects” all of the “coin” objects that match the condition. So any operations on the “coin” object will in-fact be preformed on all those “selected” objects. Any operations that are not on a “coin” object will only be done once.
The for each loop only selects a single coin object, but all operations in the loop will be run for each selected object.


It is a good answer and gives sense to this thing. I really like gdevelop but I don’t like this behaviour. It’s not the expected result and even more for an easy program to use like gdevelop.Very very confusing when you are making a complex Code in my opinion. Thanks krunkster for answer.

I don’t understand why “for each instance” is not directly the default behaviour. It would be more logical and easier to understand in my opinion.


Not entirely true, “for each” is harder for performance, since the gdevelop will have to do more “checks”.