Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Detect blocking access to parts of NavMesh

Discussion in 'Navigation' started by God0fMagic, Feb 17, 2020.

  1. God0fMagic

    God0fMagic

    Joined:
    Feb 8, 2019
    Posts:
    16
    Hello,
    I want Player to be able to be able to place obstacles for enemies on the map but I want to make sure that there is always a path from entrance to base. I could just check if path from entrance to base is valid but enemies can spawn at any tile at the edge of the map.

    My idea is that I know the number of NavMesh pieces given terrain has when I create the map. So if the number increases I will know that path for some enemies was blocked. But I can not seem to find a way to find this number. Also, if there are any other solutions for this I would love to hear it.

    A picture to show clearly what exactly I mean. Numbers from 1 to 5 show those "NavMesh pieces", with 5 being the main one where everything walks. If at any time the number rises to 6 I will know that the most recent obstacle is invalid. But I am not sure how to determine this easily.
    temp.PNG
     
  2. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    296
    You could actually block the generation of NavMeshes on the top of those obstacles by using NavMeshModifers.
     
    Last edited: Feb 18, 2020
  3. God0fMagic

    God0fMagic

    Joined:
    Feb 8, 2019
    Posts:
    16
    Yes, that is what I am doing at the moment. But I want to know if those added NavMeshModifiers will not make areas of the NavMesh inaccessible. Like placing a row of them across the field separating it in two.
     
  4. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    296
    It would be still one NavMesh, but you would not be able to cross the field with an agent, but I do not get your point tbh.
     
  5. God0fMagic

    God0fMagic

    Joined:
    Feb 8, 2019
    Posts:
    16
    I want to know that after adding a new NavMeshModifier I would still be able to access all the objects within the field.
    Checking if agent can access all of objects from all starting points seem to be a lot of calculations.
    If I can check that, I will know that the last placed NavMeshModifier is not possible and I would be able to remove it so that all areas are accessible again