c# - Unity3d 5 WavePro Dynamic MeshCollider -


im using water4advance simulate ocean waves in unity3d 5.0. have plane displaced in runtime gerstner displace. see how mesh deformed , add meshcollider , refresh collider mesh in runtime. working on unity 4.6 script:

meshcollider collider = getcomponent<meshcollider>(); mesh mesh = getcomponent<meshfilter>().mesh; collider.sharedmesh = null; collider.sharedmesh = mesh; 

but got flat original plane prefab. enter image description here

how can update meshcollider displaced mesh?

try this:

mesh mymesh = this.getcomponent<meshfilter>().mesh; destroyimmediate(this.getcomponent<meshcollider>()); var collider = this.addcomponent<meshcollider>(); collider.sharedmesh = mymesh; 

from here:

http://answers.unity3d.com/questions/446910/changing-mesh-collider-at-run-time.html


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -