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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Walkable areas ..

Discussion in 'Navigation' started by Griffo, Jun 5, 2015.

  1. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    698
    Hi,

    I wanted to know if it's possible to stop the NaveMesh baking inside empty buildings (with no way in)?

    As when i generate a new random point on the NavMesh sometimes they appear in these building and the NavAgent can't get to them.

    Or is the answer to generate a route to see if the agent can access the area, and if not spawn another point?

    Thanks.

    EDIT .. Think I might have found the answer .. NavMeshAgent.hasPath
     
    Last edited: Jun 5, 2015
  2. MysterySoftware

    MysterySoftware

    Joined:
    Sep 18, 2014
    Posts:
    46
    I think this might be what you're looking for.. :)

    Code (CSharp):
    1. NavMeshPath navpath = new NavMeshPath();
    2. NavMesh.CalculatePath (somePosition, someOtherPosition, -1, navpath);
    3. if (navpath.status == NavMeshPathStatus.PathPartial || navpath.status == NavMeshPathStatus.PathInvalid) {
    4.     // Not reachable
    5. }
     
  3. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    698
    Thank you ..