Search Unity

Is it possible to move a NavAgent to edge of NavMesh when the destination is not on the NavMesh?

Discussion in 'Navigation' started by ashwinFEC, Nov 3, 2017.

  1. ashwinFEC

    ashwinFEC

    Joined:
    May 19, 2013
    Posts:
    49
    In the example scene "4_sliding_window_infinite" and "5_sliding_window_terrain" of the github navigation package, where the NavMesh is limited to a square around the NavAgent and recalculated when the Agent moves, the NavAgent only moves when the destination is on the NavMesh. But doesn't that defeat the purpose of the on-the-fly NavMesh window calculations? Shouldn't the NavAgent move to the edge of the NavMesh that is nearest to the target? And since it is recalculating the NavMesh when the agent is moving the target will eventually be on the NavMesh.
     
    Last edited: Nov 3, 2017
  2. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982
  3. ashwinFEC

    ashwinFEC

    Joined:
    May 19, 2013
    Posts:
    49
    Well then the Unity Navigation devs should add it since other pathfinding solutions are capable of doing this. Otherwise the on-the-fly recalculation method is pretty useless for large procedural levels.
     
  4. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982

    On the fly recalculation is fine for large levels, as long as you do it at the correct point. Load in a dummy navmesh at the point that is off, link it using navmesh link, set the position, and then once your within navmesh LOD distance load in the actual navmesh and reset the desination.