I have an infinite terrain soon for asset store, I want to streamline MeshCollider creation, instead of running it on 16x16 256 tiles, I want to just create Colliders for tiles close to the player, because far away is just for viewing and MeshCollider is slow.
I have to test if tiles close to player have a mesh Collider that corresponds to the mesh shape and if no it needs updating.
Q: Should I raycast downwards from above a single vertex, and if the distance is right, assume the Collider has been created in a previous update? is there more efficient way? Like comparing objectIDs or MeshCollider vertices? And mesh vertices?
If the grid is uniform, you should simply know which tiles are near the player because of their order. Simply access the array directly and add or remove colliders as necessary.
I think I figured out the most efficient way. switch the Collider off when it is far away or hasn’t been updated to the new mesh, and check if the Collider is off to know if the mesh (which is now closed by) has been updated already in a previous proximity check.
the point is, with infinite landscape, for efficiency, the tile array is never in order, because you’re constantly moving far away tiles in corners and random orders depending on player movement, and recreating them far in front of player, in random orders also. it just uses the 1st 2-3-5 out range tiles that it finds in array. They can be from opposite corners or the same corner etc.