public static float CalculatePathLength(this NavMeshAgent navMeshAgent, Vector3 target) { NavMeshPath path = new NavMeshPath(); navMeshAgent.CalculatePath(target, path); return(path.GetPathLength()); }