Search Unity

Use NavMesh as Collision

Discussion in 'Navigation' started by Gizmoi, Dec 2, 2016.

  1. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    I've tried Googling around and found surprisingly little results. I've made a standard teleportation system for VR. I'd like to not cover everything with colliders, and the NavMesh seems to work perfectly for what I want.

    I know I can RayCast against a surface, and then SamplePosition on the NavMesh to find if a position is near the RayCasted position. But what I really want is to be able to RayCast directly against the NavMesh and see if I've hit it. Is that possible?
     
  2. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    There's currently no 3D world-space ray vs navmesh test. Will it help if we add it?

    Keep in mind: with that - it's not possible detect if you're sending the ray through a wall (not represented by navmesh geometry) and hit the floor in the next room.
     
    jason-fisher likes this.
  3. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    It would certainly help me. Or as possibly a more flexible solution, I don't know about performant, expose the NavMesh as a mesh, then I can use it in a MeshCollider and/or render it more easily.

    In my use case, I'm estimating a roughly parabolic arc with x RayCasts to see if it hit anything. At the moment I'm doing a RayCast for a Collider and then a SamplePosition for the NavMesh. If it hit a Collider I throw it away anyway. I've put walls in myself, but the NavMesh seems like a perfect way to 'tag' the floor, i.e. walkable area.

    So yes, I'd definitely benefit from that functionality. If not can you suggest an alternate method that doesn't result in placing lots of Colliders and deciding which ones are walkable?
     
  4. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    Gizmoi likes this.
  5. mcroswell

    mcroswell

    Joined:
    Jan 6, 2010
    Posts:
    79
    I know this is a really old post, but it seems the best place (so far) to ask:

    Can I make walls from the outer perimeter of the navmesh in some pre-runtime (aka editor) process? Making colliders is a pain and I imagine that I could create vertical box colliders from the perimeter of the horizontal triangles. I know I can get at the triangles, but how could I just get the perimeters (and ideally holes) - the edges between the navmesh and the non-navmesh? I think some modeling software calls it the manifold.

    Thanks, if anyone ever sees this! :)