- Home /
Determine if two meshes overlap, without using bounds or trigger?
My dungeon generation is progressing. Starting with a central piece, I find all the exits (empty child game objects) and expand outwards. Due to the nature of it, it is possible for pieces to overlap, and I need to be able to determine this and select another dungeon prefab or a deadend if it cannot find an appropriate piece after n tries.
I've tried using bounds & Intersects to determine if an intersection occurs. Problem with this is that the intersection registers even if they are aligned and not overlapping. Since they will always be aligned with at least one other object, this is unsuitable.
I've tried adding a non-k rigidbody and box collider as trigger to all pieces, but same issue occurs, if they are side by side, the trigger still registers as a hit.
So what I need to do is to determine if the two mesh colliders are overlapping (they can touch at vertices, but two planes on the mesh cannot overlap), without using bounds or triggers.
Any suggestions?
If tolerances are that tight, contract the colliders just a bit. Or you can contact the bounds of the two objects to compare just a bit before doing the comparison.
why can't two planes with mesh collider overlap? it's best to leave them as non kinematic until they have a hit. you mean two triangles/planes cannot share the same plane? obviously there is a way to check with vertices, perhaps you can run a script that checks any collisions and gets the hit triangles and aligns the mesh vertices of them... are they like walls? can we have a pic?