- Home /
Accessing a Collider2D's individual shapes
Hi!
In the editor, concave Collider2Ds (most of the time PolygonCollider2Ds) are rendered as a set of green convex shapes. These are different from the polygon collider's paths; one path can be concave and as such contain several of these shapes. The only API I could find to access information about these convex shapes is Collider2D::shapeCount which seems to return the number of shapes rendered. However, there's no way to access the shapes themselves... Or is there something I've missed?
I'm pretty sure one could triangulate the individual paths (using something like this) and then somehow figure out a way to put those triangles together into convex shapes, but that seems like something that the public API should give us; and especially for CompositeCollider2Ds with a custom Vertex Distance, which don't even expose the updated paths...
Is there any other way to figure out the minimal number of convex shapes required to replicate a CompositeCollider2D's actual path, and what those shapes are?
Cheers! :)