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.
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
Post a Comment