Sensing collision with a color

How to sense collision with a color

Closest you can do is the “Read Pixels” Extension. Outside of that, there isn’t any native detection of colors at all (unless you’ve tinted something), much less collision.

I tried to use that but couldnt figure out how to use that . Can u share a example or tell me

As I said, the closest you could do is that extension. It won’t replicate “I’m detecting if this object is colliding with a color”

All it can do is “Is this x/y location a specific color”.

Can’t really give a tutorial beyond that, sorry.

Isnt there an example of this extension?

If you would like to compare the colors of objects and not individual pixels, an other way to go about this is to store the color of each object inside an object variable as a text for example “red” “green” ‘yellow’, or the actual RGB value even ‘255;123;117’ and when the object collide, you can compare the values to check what color it is.

However, if you would like to compare color of instances of the same object that could be a problem, GDevelop does not support comparing instances of same object out of the box. If that’s the case, you can find lots of topics on the forum about how to check collision between instances of the same object.

1 Like