Search Unity

Is there any way to get distance of any two points on navmesh?

Discussion in 'Navigation' started by Bagazi, May 23, 2021.

  1. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    611
    upload_2021-5-24_2-26-46.png

    Any given two points,is there any way to get the "navmesh" distance between them?
     
  2. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    I made a tutorial on this not too long ago! You can view it here.

    The short answer is, you can calculate a path using NavMesh.CalculatePath to find the path, then sum the Vector3.Distance between each corner stored in the path, and that will give you the full distance, including any obstacle avoidance.
     
    Bagazi likes this.