Creating pieces for a 2D puzzle game

I’m building a kind of puzzle game where there are many pieces. It is simple 2D game. The artist created a design and gave png file for each image. But this causes problem.

33547-screenshot_1.png

In that image, the piece appears the way it should with transparent background. However, the problem is, the transparent area still exists. It causes a square/rectangular box around the piece which interferes with raycasting. When i have multiple pieces nearby, one piece is overlapped by the transparent area of another piece thereby making the selection impossible.
What are options to resolve this?
One way would be to create models in Maya or blender, but there are thousands of small puzzle pieces and modelling them is very tedious.

2 Answers

2

Use PolygonCollider2D instead of BoxCollider2D.

The polygon collider will do it's job. But the transparent area still exists and blocks raycasts.

Raycasts don't use pixels...they use colliders. So if you put a PolygonCollider2D on the object so that the collider outlines the visible areas, your Raycasts() will work correctly.

The artist sliced individual pieces into jpeg files. Then, used Maya. In Maya, Modify—>COnvert—>Texture to geometry. And we ended up having model of our puzzle pieces without much effort.