public AstarPath GetPath(Vector3Int start, Vector3Int end) { AstarPath path = null; IFeature startFeature = null, endFeature = null; foreach (IFeature feature in _dungeon.AllFeatures) { if (feature.Contains(start)) { startFeature = feature; } if (feature.Contains(end)) { endFeature = feature; } } if (startFeature != null && endFeature != null) { if (startFeature != endFeature) { List <AstarPath> paths = GetAllPathsBetweenExits(startFeature.GetExits(), endFeature.GetExits()); if (paths != null) { paths.Sort((x, y) => x.Distance.CompareTo(y.Distance)); path = paths[0]; path.Start = start; path.End = end; } } else { } } return(path); }