|
I have created a simple piece of code for adding vertices to a mesh by clicking on it. The vertex is added to the point of the mesh which is clicked. This works very well the first time. But the second time it fails to get the correct triangle from RaycastHit.triangleIndex. Here is the code, including a hack which actually makes it work. (The fact that the hack works also eliminates the possibility of this being a corrupted mesh.)
Any suggestions?
(comments are locked)
|
|
I know this is old but it showed up in Google when looking for a similar problem. User pkamat on the Unity forums solved this very same problem for me : In place of your hack, try nullifying the mesh before assigning it your new mesh :
Source of the answer : http://forum.unity3d.com/threads/32467-How-to-update-a-mesh-collider What he said. Destroying and recreating a meshcollider component is far heavier than just assigning it the new mesh. For some reason, meshcolliders don't like replacing meshes when they already have one... it will fail silently, and collisions won't work as expected. Setting it to null first will let the meshcollider accept the new mesh. Cheers
Apr 05 '11 at 10:02 PM
HarvesteR
(comments are locked)
|
