Hi, I’m messing about with generating my own 2d mesh terrain, and have gotten to the bit with collision and what not.
Now, I’ve got collision working in the sense that it works under certain circumstances, but I’m having a few problems.
Here is a video describing visually whats going on.
-First I generate a procedural mesh (big help from this tutorial if anyone is interested) with quads built from texture data, and apply it to the mesh filter of my ‘Terrain’ GameObject.
-Now after making the mesh, I convert the vertices (Vector3[ ]) of the mesh and turn it into a point list (Vector2[ ]),
then I apply that point list to the PolygonCollider2D of my ‘Terrain’ Object.
This works great until I want overpasses/bridges or caves. But when I assigned the point list to PolygonCollider, I can’t figure out how to control what vertices it connects. The creates a non-playable area (as seen in the video).
edit- My generated mesh quads are non-vertices-sharing if that helps…
-Update: Found the solution I needed. This reddit thread helped me.
Turns out I was looking to make separate collision bits (for every isolated chunk of blocks, I need a separate PolygonCollider path so they don’t connect).
– I wouldn’t have posted if I hadn’t tried for hours on end with no results. If anyone needs more info about the solution just ask.
edit-- Completely solved all issues I had with this instead:
Other thread with the same problem as mine that references the above link: