kaboom icon indicating copy to clipboard operation
kaboom copied to clipboard

Circle Shape Collider

Open peratik opened this issue 2 years ago • 2 comments

Hi,

How to add a circle shape collider?

I know area has a property for setting shape

But it seems circle colliders is not supported.

peratik avatar Nov 09 '23 12:11 peratik

Yes, I have the same problem. https://kaboomjs.com/#AreaCompOpt - the documentation says that "currently only Rect and Polygon is supported".

Circle is not supported, but given that polygon is supported, I think you can just make the polygon in the shape of a circle.

ganevdev avatar Feb 10 '24 13:02 ganevdev

The problem is that the SAT collision code only knows how to work with polygons. If this is fixed, circle areas can stay circle areas. To fix it, you need to add code to find the polygon point (not vertex, point) closest to the circle and take the orthogonal to the line connecting that point and the circle center as projection axis. To find the point quickly, you need Voronoi partitioning of the polygon.

mflerackers avatar May 23 '24 01:05 mflerackers