30-09-2022, 03:52 PM
(02-08-2018, 04:11 PM)josemendez Wrote: Just for the record, imho this all seems like a terrible idea. Modifying the collider mesh will force Unity (and Obi) to re-generate the internal hierarchical representation of the mesh geometry (in Obi's case, a multi-level hash grid), which can become much more expensive that the cloth simulation itself depending on how often you do it. You will also run into a lot of tunneling issues with collision detection (as MeshColliders aren't convex in the general case, thus being treated as paper-thin instead of solid volumes).
This being said, you might be able to modify Obi slightly to support modifying the collision mesh at runtime:
- Go to ObiColliderBase.cs and change the "tracker" declaration from protected to public (line 65).
- Get your ObiCollider component, and call this:
Code:((ObiMeshShapeTracker)collider.tracker).UpdateMeshData();
I cannot guarantee 100% that this will work, as it was designed to update the mesh once at startup. There's a pretty good chance that it will, though.
My advice regarding this would be to use signed distance fields. You can precompute pretty much all of the collision information (distance, gradient), they can be blended together via relatively simple operations (useful in flexible regions such as elbows and knees in case you need realtime animation) and can be regarded as solid volumes even for concave shapes, so that tunneling becomes less of an issue.
Hello, sorry about stupid question im not a programmer, but where should I call component? I need to write some code or there is some option? thank you