- Home /
Updating Dynamic Mesh's Collider is Too Slow
I'm making a pottery application. The pot is very large, it's 31400 verts and I'm sculpting it's mesh each frame. All of that is working out well. Now I want to add some physical properties to the pot's mesh so my hand does not go through it.
//in a nutshell, I blast my verts into Unity, from a magical DLL each frame
//something like this.
myPotMesh = MagicalDLL(myPotMesh);
//and each frame I set the Mesh Collider to that mesh
myMeshCollider.sharedMesh = myPotMesh;
//but it will still only reference the mesh that was set the first time around, despite me setting it each frame!
//So instead I try also resetting it each frame. This works, but is very slow!
myMeshCollider.sharedMesh = null;
myMeshCollider.sharedMesh = myPotMesh;
The Mesh Collider must make a copy of that mesh and then no longer refer to it, despite me explicitly setting it each frame.
Any suggestions would be appreciated. I'd like the mesh collider to refer to a mesh without having to make a copy of it, if it's possible.
Thank you
Answer by Eric5h5 · Dec 12, 2013 at 08:22 PM
Setting a mesh collider is slow and there isn't a way around it, since it requires heavy processing. If you really need to update a mesh collider dynamically, the best thing you can do is use as few vertices as possible.