For top-down 2D games based on static sprite (i.e. not utilising regular squares as made by pixel art, or not resolving by setting collision on objects. I don’t even know how to describe it!), what is the correct way to set collision for the map?
The following screenshot is from a previous project of mine. At that time, I solved the problem by manually arranging the box shapes.
The problem with this method is that,
- The more complex the map shape, the more box shapes there are, which increases performance concerns
- It is time-consuming.
So I decided to try Convex hull shape (Physics Body Editor was deprecated, so I used Defold Polygon Editor web version).
Below is the results of the experiment.
The left side is the approach that arranges box shapes, while the right side relies on .convexshape.
As you can see in the video, the collision behaviour is unstable and the shape is often wrong when exporting. Besides, there seems to be a limit to the number of vertices that can be set. Apparently, .convexshape with the Defold Polygon Editor is probably not intended for use cases like mine.
At the moment, the only solution seems to be to manually align the box shape in detail, but if anyone knows of a better solution to this problem, please let me know.