Search Unity

Getting more information about a path?

Discussion in 'Navigation' started by jwvanderbeck, Feb 21, 2019.

  1. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    I'm trying to dig deeper into data about the path chosen by a NavMeshAgent, but looking at the docs for AI.NavMeshPath at first glance I'm not seeing much information.

    What I am hoping to find is information such as:
    1) What NavMeshSurface objects are in the path
    2) What NavMeshLink objects it is using
    3) The distance or length of the path
    4) The cost of the path

    Is there a way to get at this information?
     
  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Only one I can easily answer is the Distance. You can get the corners of the path and then use those to calculate the distance between them.
    As for surfaces and links, a bruteforce way of dealing with them is to sample positions along the path at set intervals and check for nearby link and surface objects, then see if the surface volumes and link corners intersect with the path.
    If they do, you can then take the surfaces' costs multiplied by the distance traveled over the surface, and combine them to get the final cost of the path.