In Collision with Color Condition, and Separate Object from Color Action

It would be nice to see a “In Collision with (Customizable Hex Color)” condition, and a “Separate (Object) from (Hex Color)” action. If these were added I’d like to see a ignore opacity option so collision maps wouldn’t have to be visible. This would make it so much easier to do collisions, because you could have a collision map as a certain color, then set it’s opacity to 0 so it’s not visible In-Game.

So, I’m not an engine dev or contributor, but:

  1. Could you explain what this adds over using separate hitbox objects in an object group that you hide at the beginning of the scene?
  2. Do you know of any other engines that do collision this way?
  3. Unless I’m misunderstanding, this would instead mean that the engine would need to check collision for every possible pixel in the game, rather than the collision polygons it does right now. That seems exceptionally resource intensive.
1 Like

For one it’s just an idea. It would be easier than using separate hitbox objects, because if you want to have detailed collisions on large maps, it would take several hundred hours to map out with polygons. I can’t think of any engines, but the beginner coding site Scratch has a similar option. Finally, it would not have to check collisions for every pixel, just if a certain sprite is colliding with a certain color.

1 Like

You can have an object as “blockage” place it on map where ever you want collision.
(If I got you right)

Finally, it would not have to check collisions for every pixel, just if a certain sprite is colliding with a certain color.

So, just to clarify on this, as far as I know the only way this works is if:

  1. The engine is literally monitoring the color of every single pixel
  2. The x/y position of that color/pixel
  3. Compares the collision hitbox of the sprite with those items above.
    Every single frame.

I don’t know of any other way you could track what color a pixel is. This is mostly because the renderers don’t care about the content of a sprite (it doesn’t know what the image is, just that it’s an image and whatever its boundary box is), so you’d have to start tracking that for any maps to be able to do this.

As far as taking several hundred hours to map out polygons, not really. You’re just taking a square and stretching it to the width of every surface. It doesn’t have to be exactly the size of the platform’s height on the map, just the proper width if it’s a floor, or height if it’s a wall. so long as it’s more than say, 5 pixels wide/tall, it’ll act proper for collisions. Copying/pasting a hitbox object is as easy as ctrl+c and ctrl+v, so it’s pretty quick.

Source: I’ve done this in numerous examples so far, with multiple scenes of 5000x5000 map sizes (final size after combining numerous maps) or more. It usually takes about 5-10 minutes to map out the platforms.

Now, ALLLL of the above said. If an actual engine contributor can think of a way to make this work, it could at least be something worthwhile for the trello board. It may duplicate the benefits of the Tile Map Collision layer drawing that will be coming eventually with the Tiled Import (I don’t know if that’s an initial release thing or future support).

Collision by colors are not a great idea, the math are:

For a 1920*1080 screen, 2073600 pixels to test, if you have 4 colors, multiply 2073600 by 4, 8294400 operations
Only for verify if something is in collision with a specific colors.
It’s enough for make games crashing on small hardware.

The collision engine works with points (bouding box), all is maths trigonometry because it’s faster.

At the very least I think the collisions editor should be reworked to be easier to use, right now it’s kind of a pain if you want custom collisions

1 Like

The engine could pre render or creating collision masks for such color in order to avoid this. Scratch is a simple tool and has this feature without any problems. I think a better solution could be a “magic wand” for collision masks

Generating a default collision mask in IDE from the colors is a possibility indeed, but that’s not checking collisions with a color, and a whole other feature request which has already been made multiple times. Scratch is in no way comparable to GDevelop as at no point it was designed as a full-fledged and professional game engine.

Definitely agree with @Nttgames, I made a feature suggestions to help improve the creation of collisions and points.

As far as creating a lot of mapping, I’m not sure I understand? I have a rectangle, triangle, and circle sprites and I use those to create boundaries. Certainly doesn’t take hours to map a scene. How are you doing it in your games?