Search Unity

How to determine if two meshes overlap, without using bounds or trigger?

Discussion in 'Scripting' started by lukasaurus, Sep 1, 2014.

  1. lukasaurus

    lukasaurus

    Joined:
    Aug 21, 2011
    Posts:
    360
    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?