GDevelop appears to not always remove a deleted object when the object is deleted within a repeat block.
If my logic is correct, the following event snip should remove the 4 closest rock objects to the player if at least 4 are within 100 pixels of the player. But it only deletes 1, and I believe this is erroneous.
To confirm, I added an Id variable to the rock object, and used the following to output the number of suitable rock objects, and ids of the rock object being deleted.
GDevelop appears to be repeatedly deleting the same object. This slightly modified version of the previous events screen snip :
resulted in this console output, which suggests GDevelop is removing the same rock object 4 times :
This set of events do remove up to 4 of the nearest rock objects to the player object, but that not quite the same as deleting 4 rock objects if 4 or more of them are closer than 100 pixels :
Yeah, I’ve got it deleting 4 rock within 100 pixels no problems (it’s in that last screen snip of my first post).
It’s when I add a check that there are at least 4 rocks to delete that the problem occurs. There are more than 4 rocks to delete (the console.log shows that), but it picks the same one 4 times, and deletes it every iteration.
For some reason, the list of candidate objects isn’t being reduced in one scenario, while it is in another.
If I remove Trigger Once, it deletes all of the expected objects (because it’s repeating every frame), with the trigger once, it deletes only 1 object.
It almost as if any action or condition that refers to the objects being repeated over prevents the delete from reducing the list of candidate objects.
Hmmm…It could have to do with the Count() expression. It is one of the few expressions I know of that messes with the object list.
The “Number of objects” could be doing something similar.
What if you add another subevent to your “repeat” and add the log message there? put it above your pick/delete event, but keep it as a subevent instead of in the parent event?
This works. I don’t like that it requires this extra step, but it works.
Where as this doesn’t, because it has the Count expression in the parent event.:
Thanks for the GitHub link @Silver-Streak, one of the work arounds mentioned by 4ian is very similar to one I had implemented to get around the issue. But I like your one better
In your screenshoots is missing the condition by comparing the distance between the two objects (below 100 pixels). I did a test changing the position of “rock” and this worked:
4ian is coming up with a potential longterm solution (new number of object conditions/count expressions), but for now all you’d have to do is put the “Rock distance to player is below 100 pixels” in the same event I have the count expression in. It’ll narrow the results of the count expression.