There is a bug where the physics act weird because the automatic LOD meshes also have many collision meshes instead of a single shared one.
Basicly it makes everything more slippery then it needs to be.
Since I don’t have high hopes for a fix on this matter, I want to try and have a script that automaticly disables the collision mesh for all gameobjects named *LOD1 *LOD2 and *LOD3 as that fixes the problem I have.
Now I understand how to find a gameobject with a specific name, but how can I find gameobjects with a specific part of their name?
Use Resources.FindObjectsOfTypeAll. This will return all of the objects that have been loaded into memory, of a given type.
// Build a list of all Meshes that exist in memory
var loadedMeshes = Resources.FindObjectsOfTypeAll(typeof(Mesh));
foreach (var mesh in loadedMeshes)
{
// Find only those meshes that in LOD1, LOD2, or LOD3
if (mesh.name.EndsWith("LOD1")|| mesh.name.EndsWith("LOD2") || mesh.name.EndsWith("LOD3"))
{
// Turn off the mesh collider
mesh.collider.enabled = false;
}
}
Just be careful with when you call Resources.FindObjectsOfTypeAll
because it’s extremely expensive, computationally.