Search Unity

Navigation area under a building?

Discussion in 'Navigation' started by Shadowing, Sep 29, 2019.

  1. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I have this issue where my AI agent thinks he can go under this building.
    I'm finding a random spot that the AI can walk towards. Then I use NavMesh.SamplePosition to find the closest spot on the nav mesh.

    So idk whats the best way to handle this. Add a collider under the building so it gets rid of the nav mesh? Or figure out why he think she can go under the building.

    i wouldn't think i could set a path to that position since his Agent height is higher than that area Or also he would have to go through that wall that has no navmesh on it.

    I tried setting autoTraverseOffMeshLink to false.
    I do have autoRepath on. I do notice that he stops at the building. He doesn't try to keep running into the wall. But i also have something on my controller that stops the controller from trying to run into a wall too by using a ray cast.

    So I guess i don't know if he is just making a new path cause that point inside the building becomes in valid or what. Guess i need to test a little more and rule some things out.




     
  2. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    TargetPosition is the same as ActualNavmeshPosition.
    so its not being repath.


    Code (csharp):
    1.  
    2. Vector3 ActualNavmeshPosition = m_NavMeshAgent.destination = TargetPosition;
    3.  
     
  3. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Apparently the entire building is all hollow out with no floor. Thats why the agent has enough height to fit inside it.
    I don't understand how the Agent can plot a path to get inside it. It would have to go past unwalkable areas.