I am creating a 2D sprite game in Unity, which is a 3D game development environment. I limited the entire transfer of objects to the XY plane and rotation to the Z axis.
My problem is that the meshes that are used to detect conflicts between objects still have to be in 3D. I have a need to detect collisions between a player’s object (capsule collider) and a sprite (which has its own level of collision defined by a polygonal prism).
I am currently writing a level editor, and I need to let the user define the collision zone for any tile. In the image below, the user clicks the points P1, P2, P3, P4 in this order.

Obviously, the points are connected to form a quadrangle. This is the collision area that I want, however I have to convert it to a 3D mesh. Basically I need to create the extrusion of a polygon, then assign the vertex winding and triangles, etc. The positions of the vertices are not a problem to determine, since it is simply a translation of the polygon down the z axis.

I had a problem with creating an algorithm for setting the order of winding vertices, especially since the grid should consist only of triangles.
Obviously, the structure that I illustrated does not matter, the polygon can be any 2d-shape and will always have to form a prism. Does anyone know of any methods for this?
Thank you very much for your time.
source
share