[Done V5.2.167] Automatic Collision Masks/Collision mask "Magic wand"

Update: a simpler version (not convex since it has been evaluated as not ideal) for automatically calculated collision masks has been released on Version 5.2.167.

Would it be possible to add in future releases something like “magic wand” of photoshop for collision of objects?
conrtno

This would be useful if an object has different shapes and even sizes.And even, you want to modify the collision locations to be as perfect as possible.

7 Likes

That’s a cool idea.

Unfortunately, GDevelop only supports Convex hitboxes, so a magic wand would give you a hitbox that you could not use, such as with your example your sprite.

After some digging, concave support for hitboxes in 2D engines is pretty rare. (Not supported by Construct, Is faked by Game Maker Studio (they add multiple polygons to simulate concave structures, then merge them), not supported by Defold, etc)

Even some 3D engines like Buildbox don’t support them.

A contributor might be able to chime in more on the feasibility, though.

2 Likes

I understand that it can be a little bit of work, but I believe in the possible. It doesn’t necessarily have to be perfect like the magic wand, but something that helps and saves time for some objects would be very useful.

I agree that most game engines (including GDevelop) only support convex shapes. However, I think that @willianholtz is asking for GDevelop to automatically generate the best convex hitbox shape automatically, also known as a convex hull algorithm.

Here is a popular javascript library (that was just added to the three.js). I think it would be very valuable to add this feature (especially if physics objects ever support a custom collision shape!)

Oops, that is for 3D objects, so it is probably not the best fit for GDevelop (unless it can function well using 2D input). I did find some 2D only tools, but it’s hard for me to know which one would be best. For example:

Cheers,

Tristan

7 Likes

I added this as a Feature Request on Github:

2 Likes

Thanx @tristanrhodes

Yes this will be cool then when we make pixel art it makes to hitbox for me

1 Like

Hello everyone!
I am letting you know that this feature is officially under review, so I have a couple of questions regarding your demands.

I was wondering why would you like to have a custom collision mask rather than a square/rectangle on your object: How does a custom non-squared collision mask improves the gameplay of your game?

3 Likes

I see new users come to discord making their first game and going with ULTRA shape detailed collision masks
I find that very stupid
Like what is benefit of being that precise?

But just because i don’t use it does not mean it is not worth existing for other users
For example i don’t use tik-tok cause i found it being stupid platform
But if someone want to use it then why not?

Anyway i bet in most cases most users DO NOT need that precise collision masks
They just want it because they falsely believe it will improve anything

Personally i always go full rectangle

BUT on VERY ULTRA rare occasions i could find other shapes than rectangles useful
But it would not be something that i would need rather something i want
I can’t see any situation where i could not go with just rectangles

For the original example here, I’m not sure that this would be useful as the platformer character behavior only takes into account the AABB (rectangle) of the widest point and tallest point when using that behavior. Even if the engine automatically made the mask the shape of the sprite, it would still only count the widest point to the tallest point. Users tend to be confused about this, which is what leads them to asking collision mask questions.

That said, if the feature automatically made the smallest rectangle possible over non-transparent pixels, maybe that could help for platformers? Otherwise you’d need to rework the platformer behavior again to support non-rectangular masks and avoid the old elevator/moving platform/angled platform issues.

Where automatic collision masks might be more helpful is something like an adventure game, where you only want clicks to happen over an object’s visuals (using the “Point is inside object” condition). In most cases those aren’t sprites going to be rectangles, and automatically adjusting the mask to the shape of the visible pixels would be useful. Touch focused games (non-platformer) on mobile could get use out of that in a similar way.

Overall, I would only want it automatic in that there’s a button on the collision mask editor to make it automatically resize, I wouldn’t want it adjusting the mask by default. That’s just my personal preference, though.

3 Likes

Yes. Most of the time it does not benefit, but in some cases it maybe useful for top down. Precise hitboxes. I would use it for other stuff besides players. Like if I had a circle as a sprite. I would like a circular hitbox.

2 Likes