Hi all,
If you apply procedural changes to a mesh with a mesh collider attached, is there a simple way to dynamically adapt the collider to the new shape ?
Hi all,
If you apply procedural changes to a mesh with a mesh collider attached, is there a simple way to dynamically adapt the collider to the new shape ?
Yes, something like “GetComponent(MeshCollider).mesh = myNewMesh;”
–Eric
…and it works ! Another big thank you, Eric
[edit] more precisely : GetComponent(MeshCollider).sharedMesh = mesh;
Is it possible to do the same with a skinned Mesh?
I’m modifying the shape of an object using bones but I need the collider to match the deformed shape.
How do I access the modified mesh? the Skinned Mesh Renderer component gives me access to the shared mesh, but that’s the mesh at the time of the import, I need the current instance of the mesh which is the one that’s deformed by the bones so I can assign that to the meshCollider.
Thanks
Luis
I don’t think there’s a way to read that from the graphics card.
–Eric
So, what I’m trying to achieve is not possible? Any workaround or suggestion you can think of?
I’m making a configurable container, ie water tank, the user will be able to configure the size of certain parts of the tank to create different types of tanks then I simulate the water in the tank using particles, this is the reason why I need the mesh collider to match the skinned model.
I’m using bones at the moment because its the easiest way I can think of to modify the geometry, without having to keep track of which vertex index corresponds to what part of the geometry and to move all the vertices attached to that part in a intuitive way.
Any help, ideas or suggestion will be greatly appreciated.
Thanks
Luis
Might have to do it the hard way, I’m afraid, unless somebody else has a better idea.
–Eric
I managed to do it using the code found in the following link:
http://forum.unity3d.com/viewtopic.php?t=16698&highlight=vertex+count
It’s slow but it works for what I’m trying to do.
Thanks for the help.
Luis