- Home /
Too many colliders?
I have a problem with performance when creating my mesh terrain, currently it creates 6144 convex colliders for each of the 6144 chunks in the terrain, it takes around 70 seconds to create/initiate them all which clearly needs improvement. I am adding the collision with this script:
public IEnumerator AddColliders()
{
mc0 = GetComponent<MeshCollider>();
mc0.sharedMesh = mesh;
yield return null;
if (mesh.vertices.Length > 3 && mesh.triangles.Length > 3)
{
mc0.convex = true;
}
}
I have around 600fps after they are created, which is perfect.
6144 seperate gameobjects is too much for Unity.
Assigning colliders to gameobjects is very resource-intensive
The solution is to implement a LOD (level of detail) system that either simplifies those colliders that are far away, or only keeps track of gameobjects (chunks) in the vincinity of the player/camera.
The problem is I created a LOD system, but should I use submeshes ins$$anonymous$$d of a new gameobject for each chunk?
I thought it would be a better idea to generate all the colliders on startup with the highest LOD quality, this doesn't seem to be the case. Do you have any ideas for improvements of this system?
$$anonymous$$ake the chunks as big as possible (65k vertices limit), and see what it does. Read some articles in $$anonymous$$inecraft-style games and how they generate chunks.
Your answer
Follow this Question
Related Questions
How do i prevent an imported Mesh from falling through Terrain? 3 Answers
Mesh collider cost 1 Answer
Mesh Collider HELP - 1 Answer
MeshCollider vs. anyOtherCollider 1 Answer
Terrain Detail Mesh Collisions 1 Answer