Creating 3d cube / mesh from 2d collider

Hi! I have 2d polygon collider or edge collider on sprite (it fits the shape of sprite perfectly). I would like to create 3d mesh (or mesh plane) which is the same shape of collider but has also Z value, so 3d physic can collide when stepping on it from top. Programmatic way is preferred. I have seen that it is possible thanks to Unity example.

Thanks in advance!

Ok. I have noticed that there is ready 2d ColliderGen. I have watched the video presenting this 2d collider generator. For me it is too powerful (and complicated in practice) and also I didn’t have guarantee that it will suite my case…

So I have learned a bit about mesh and written some script to generate mesh collider from sprite of Unity 4.3.

Now I can use 3d physics with my 2d sprites :wink:

The idea was to add polygon collider 2d (just for time of generating mesh collider) and get its points. The points create the stroke of sprite so I have used them to create vertices on the sprite side and mirror of them on side defined by Z coordinate. Finally I have defined triangles like ping-pong - going from vertices on one side, to the other side. This way I got mesh which is a surface in Z space of sprite. I have shared this mesh with a filter and a collider of a cube which has the same position as sprite.

I wonder why 2d collider can’t collide with 3d colliders. It would be a lot easier for everyone…

Thanks and bye!