Answer the question
In order to leave comments, you need to log in
How to programmatically calculate colliders for sprites?
The pictures show examples of spritelists with rendered round colliders given as the coordinates of the circle's center and its radius.
Answer the question
In order to leave comments, you need to log in
There is a family of algorithms called Convex Hulling that allows you to wrap an image into a primitive with the required accuracy.
The resulting primitive contour can already be used for filling with colliders, also with the required accuracy.
To fill a primitive with colliders, an algorithm from the Bin Packing family may be suitable . They allow you to take into account the overlap and inaccuracy of filling the contour.
As a result, when selecting implementations and adjusting the criteria, you can get a result comparable to those shown in the images.
However, personally, I would recommend stopping at the outline of the image primitive. If these are all really colliders, then testing a single closed polygon would be cheaper than testing a potentially infinite collection of circles.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question