- Home /
Strange Behavior of Mesh Collider for Dynamic Mesh
Hi,
I am getting crazy with a mesh collider that does not want to work.
I believe, I am missing an update function call but I don't see where.
What makes me suspect this, and, what is really strange is that if I change the physical material in the inspector at run time then the mesh collider detects the collisions correctly.
Basically, the mesh is created by a script during the update function of the component.
The script is very similar to the procedural mesh samples provided by unity in its sample collection.
- I tried different methods of initialization of the mesh collider and of the physical material but it seems that does not change anything. The physical material loaded is "wood".
- I am using sharedMesh , and sharedMaterial all along the way. I also did try to reaffect them as necessary...
- The loaded material is present in the inspector at runtime.
- I tried attaching a rigidbody in kinematic mode it did not change the result.
- I tried calling various update functions such as RecalculateBounds() or WakeUp(), no effect...
Does anyone had similar experience ? or have one idea of the the reason that would explain why chaging the material in inspector starts make working the mesh collider, and what kind of call I may be missing to make work the mesh collider.
Thanks for any help...
Bertrand
Answer by Bertrand · Dec 11, 2010 at 10:40 AM
Well, I believe I have finally found out what was going on... I had left some degenerated triangles(all nodes to the same vertex) in my mesh, these one were not visible and had not effects, except that removing them, re-enable the collision with the mesh...
It is likely that these degenerated triangles in the mesh were generating a "division by zero" exception in the meshcollider code... and that for this reason the mesh collider code was returning without reporting collisions.
If this is the correct explanation, I believe a warning should be issued to inform the developper of that collisions have not been handled due to some invalid triangle in the mesh.
Answer by shinriyo_twitter · Oct 13, 2011 at 07:22 AM
I did like this [CODE] MeshCollider meshCollider = GameObject.Find("YOUR TARGET GAME OBJECT").GetComponent(); meshCollider.convex = true; [/CODE]
Your answer
![](https://koobas.hobune.stream/wayback/20220613090607im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Prevent Fallthrough with Procedural Mesh and Collider 0 Answers
Turn Off Mesh.Bake Scaled Mesh PhysX CollisionData ? 0 Answers
AAPT Failed! 0 custom asset files in raw for Procedural Examples Paint Vertices to Android 2 Answers
Collision with Plane fails 0 Answers
MeshCollider is not getting updated when adding vertex to mesh 1 Answer