public List <Vector3> GetPath(Vector2 start_, Vector2 goal_) { pathPlanner.PathplannerParameter param = new pathPlanner.PathplannerParameter(); param.startNode = pathplannerMap.GetNodeByIndex((int)start_.x, (int)start_.y); param.goalNode = pathplannerMap.GetNodeByIndex((int)goal_.x, (int)goal_.y); Array <object> nodes = pathfinder.FindPath(param); List <Vector3> path = new List <Vector3>(); for (int i = 0; i < nodes.length; ++i) { Position pos = ((Node)nodes[i]).GetPosition(); path.Add(new Vector3(pos.GetX(), 0, pos.GetY()));// y has no effect } return(path); }
public pathPlanner.GraphGridMap LoadMap(string filePath_) { string[] fin = ReadLines(filePath_); int height = int.Parse(fin[1].Split(' ')[1]); int width = int.Parse(fin[2].Split(' ')[1]); pathPlanner.GraphGridMap map = new pathPlanner.GraphGridMap(width, height); for (int y = 4; y < fin.Length; ++y) { for (int x = 0; x < width; ++x) { char value = fin[y][x]; switch (value) { case '.': case 'G': case 'S': map.GetNodeByIndex(x, y - 4).SetTraversable(true); break; case '@': case 'O': case 'W': case 'T': map.GetNodeByIndex(x, y - 4).SetTraversable(false); break; default: Debug.Log("something went wrong in loading map: " + filePath_ + " : " + value); break; } } } return(map); }