Search Unity

detecting if navagent is using unreachable path?

Discussion in 'Navigation' started by adventurefan, Jun 27, 2021.

  1. adventurefan

    adventurefan

    Joined:
    Jan 17, 2014
    Posts:
    230
    navmeshissue.jpg



    So in this game I want an agent that makes path AVOIDING the other agent.

    However everything with the pathfinding system seems to simply mark a path as complete if there's ANY SURFACE out there that has navmesh on it... which is a bad looking behavior that moves an agent to random looking spot. Is there a way to disable that "feature"... I can think of some ways to raycast and do more pre-checks myself but it seems like something people should have control over without extra coding?
     
  2. adventurefan

    adventurefan

    Joined:
    Jan 17, 2014
    Posts:
    230
    Ok so after too much time experimenting with how the path systems are generated found a good solution to this!

    If the target is unreachable, the final point in the array of path corners will NOT MATCH your target destination. I didn't realize this because it still saves the actual final target somewhere. But this makes it pretty easy to just compare the final point in any calculated path and if doesn't match the real destination you want, you can exclude doing anything further with it. (I just compared the x and the z's of both because Y can be a bit different due to agent size.) So fortunately there is a real simple way to handle this. :)
     
    The_ZayNepz_Guy and JasonBSteele like this.