// Create a path from one world position to another. (in 2D) // Can be configured to search using diagonals. // Dynamic path's recalculate the path when encountering obstacles from the obstacles position. // Static path's recalculate the path when encountering obstacles from the paths original start position. public bool CreatePath(Vector3 startPosWorld, Vector3 endPosWorld, bool searchUsesDiagonals = true, bool isdynamic = true, int overrideiterations = 0) { DebugClearMarkers(); // Resets this path if there already is one. if (IsGenerated()) { Reset(); } startpos = startPosWorld; endpos = endPosWorld; Vector3Int startNavPos = pf.WorldToNav(startPosWorld); Vector3Int endNavPos = pf.WorldToNav(endPosWorld); searchWithDiagonals = searchUsesDiagonals; isdynamicflag = isdynamic; // The A* object only uses Nav grid coordinates. return(aStarSearch.StartPath(startNavPos, endNavPos, pathpoints, searchWithDiagonals, overrideiterations)); }
// Create a path from one world position to another. (in 2D) // Can be configured to search using diagonals. // Dynamic path's recalculate the path when encountering obstacles from the obstacles position. // Static path's recalculate the path when encountering obstacles from the paths original start position. public bool CreatePath(Vector3 startPosWorld, Vector3 endPosWorld, bool searchUsesDiagonals = true, bool isdynamic = true, int overrideiterations = 0) { DebugClearMarkers(); // Resets this path if there already is one. //TODO make it so if we need to regenerate a path due to a new blockage, that we continue on the old one until we hit the blockage //or until the new path is ready if (IsGenerated()) { Reset(); } startpos = startPosWorld; endpos = endPosWorld; Vector3Int startNavPos = pf.WorldToNav(startPosWorld); Vector3Int endNavPos = pf.WorldToNav(endPosWorld); searchWithDiagonals = searchUsesDiagonals; isdynamicflag = isdynamic; // The A* object only uses Nav grid coordinates. return(aStarSearch.StartPath(startNavPos, endNavPos, pathpoints, searchWithDiagonals, overrideiterations)); }