Mesh collider on procedurally generated mesh

Hi,

I'm having a problem assigning my mesh a collider.

I've tweaked the CrumpleMesh scene (from the procedural examples package) and now have a flat plane that, on run time, is deformed by Perlin noise. I can assign the mesh itself a collider but this does not follow the contours of the deformed mesh (e.g. the hills and troughs).

So- in light of the above, what would be the best way of assigning a collider to my mesh after it has been deformed (I imagine I need to add something to the script, but can't quite work out what).

1 Reply

Copy the generated mesh to the meshcollider's mesh. i.e., GetComponent<MeshCollider>().mesh = _mesh;. Keep in mind that updating a mesh collider is very slow, and not actually something you want to do in Update.