Can I have the collider for lower detail meshes in a lodgroup have automaticly disable the mesh collider?
For example having a lodgroup with 3 meshes means there are 3 collider meshes in roughly the same space while I would only need 1.
This leads to alot of unexpected behavior like invisible walls caused by a lower lod model collider and also weird physics behavior in my ball physics game.
Like surfaces being slippery that aren’t that fix themselves if i disable a lod collider.
Having to go trough every model in my levels will take alot of time so i wonder if I can tell the fbx importer to have the lodgroups lower detail meshes have no collider.
LODGroups only seem to be able to work on renderers in Unity3d. A workaround is to attach a script to the parent gameobject that will disable all child colliders by name at startup. Here’s a sample method you can use to achieve it:
private void DisableCollidersRecursive<T>(string nameMatcher = null) where T : Collider
{
Regex matcher = string.IsNullOrEmpty(nameMatcher) ? null : new Regex(nameMatcher);
foreach (var collider in gameObject.GetComponentsInChildren<T>())
if (matcher == null || matcher.IsMatch(collider.gameObject.name))
collider.enabled = false;
}
For instance you might set the input parameter as “.*_LOD1” to target only first level LODs.