Have rigidbody convincingly follow GPU mesh deformations of plane mesh?

I’m trying to make a rigidbody roll along the deformation of a plane mesh underneath it.
However, the mesh is being deformed through GPU, which apparently the rigidbody isn’t naturally detecting.
How can one communicate to the rigidbody where the GPU-deformed mesh vertices are, so that the rigidbody can position and convincingly roll along the GPU-deformed mesh vertices?
The mesh gets deformed dynamically in realtime so this is not easy (for me) to capture in a formula.

Easiest would be to remove and re-add the MeshCollider component. But you can expect this to cause framerate hiccups, more so the more vertices the mesh has.

There are reasons why runtime deformation of meshes and their collisions is rarely done. One is performance, and the other is unexpected side effects for gameplay. For example the player could find themselves in a trap, or fall through the terrain, or exploit the deformation in some other way.

1 Like

The only points of collision required are around the location of the rigidbody. So if you were able to sync a small area around the rigidbody with the calculations performed on the GPU it should be possible. That is, calculating a virtual mesh collider deformation that matches the visible mesh around the rigidbody.

1 Like