Collision test - inverted and NOT

Here are the interesting results from a quick test I did of the collision condition, using normal, inverted (the ‘invert’ toggle in the condition) and NOT (the advanced NOT condition) variants…

Note: the red line shows which object is being highlighted red in the event action.

For example:


1 Like

The first two results (the ‘regular’ set) are as expected.

Of the ‘inverted’ results, the first is expected, but the second isn’t. But as I think about it, it makes sense. GDevelop’s way of ‘picking’ objects is what causes this result - the inversion basically means ‘circle is not in collision with any square’. So when you highlight the picked circles, you get the two as expected. But when you highlight the squares, you’re getting all (any) of them, because they’re not filtered at all.

The ‘NOT’ results at first don’t make sense, but when you convert the results to booleans then it does. The ‘circle is in collision with square’ condition is TRUE, because there is at least one circle colliding with at least one square. So when you do NOT that, you get not TRUE, which is FALSE. Therefore the action doesn’t run and nothing gets highlighted.

So yeah, all makes sense when you understand a bit more about how how GDevelop works under the hood. It’s just not immediately obvious or intuitive. Hope this helps someone :smile: