How to get a 2D polygonal sprite to collide with a Mesh Collider

This is a rather simple question. I have a 2D sprite that really needs the precision of a polygonal hitbox. The 2D, tile-based world around it uses a tile Mesh for efficiency reasons, and thus has a Mesh Collider.

Before, the tiles in the world were each GameObjects with Box Colliders and Rigidbody 2D’s, and the ship and the tiles collided just fine. Now that I am using a Mesh Collider, however, they cannot collide. (I have read that this is because one is 2D and one is 3D.) So what should I do to get collisions (preferably with rigidbody physics) between a polygonal ship and a 2D tile mesh?

(Here is the collision mesh I am using.)

2 Answers

2

To surmise the comments to this question

  • Meshes are 3D. Polygons are 2D. They exist in separate physics systems and cannot collide.
  • Polygons are the 2D equivalent to a Mesh
  • Using a polygon collider is the best option

Also worth noting that you can edit a polygon collider dynamically by using SetPath. This should give you all of the functionality from your mesh.

The physics engines aren’t compatible, use 2d/3d colliders only.

But there is no Polygon Collider 3D. I don't want to use a box collider.

I don't understand the problem, if you want to use 2d physics, then use 2d colliders only, if you want 3d, then use 3d colliders, there is no workaround since they are completely independent from eachother.

The problem is that among the list of colliders in the Physics section, I can only see Box, Sphere, Capsule, Mesh, Wheel, and Terrain. None of these would be precise enough for my needs, unless I used three or four (at least) per sprite. I am looking for a 3D analogue to the Polygon Collider. Otherwise, I am looking for a 2D analogue to the Mesh Collider. Since I need to use both of these, I need to find an equivalent for one of them — but it doesn't seem like those exist.

Polygon collider is the 2d equivalent of the mesh collider. What are you trying to do exactly? Can you post an example image?

jeez this drives me nuts. I find a post that is exactly what i'm looking for and it's a dead post.,