Using Polyline Mesh for Mesh Collider

Avatar
  • updated
  • Answered

I'm attempting to create a polyline at runtime, and then using the generated mesh for a mesh collider. I understand that the mesh is generated via shader code, and that there isn't an easy way to access that back on the CPU, but I wonder if you have any suggestions on how I might recreate the mesh on the CPU side. I noticed there was a pretty substantial ShapesMeshGen.GenPolylineMesh function, but I suspect that's only half of the equation.

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
Freya Holmér creator
  • Answered

this isn't possible, because the polyline mesh that is generated has 0 thickness, the thickness is applied in real-time in the vertex shader, and is non-trivial to simply apply to a mesh afterwards. You could retrofit the polyline mesh to work that way in specific cases, but it'd take some work. Easiest would probably be to duplicate the polyline mesh generator function and add the extra thickness there by hand

Avatar
giant light matt

Appreciate the reply, I suspected that might be the case. Thanks for the suggestion!