List <Vector2> SearchForPath(Vector2 startPos, Vector2 endPos, int[,] mapWeights) { int[,] newWeights = (int[, ])mapWeights.Clone(); foreach (var loc in eventedLocations) { newWeights[(int)loc.x, (int)loc.y] = eventedLocationWeight; } foreach (var loc in occupiedLocations) { newWeights[(int)loc.x, (int)loc.y] = occupiedWeight; } SearchPoint start = new SearchPoint((int)startPos.x, (int)startPos.y); SearchPoint end = new SearchPoint((int)endPos.x, (int)endPos.y); List <SearchPoint> path = Pathfinding.CreateConnectingPath(start, end, newWeights, true, 10000); List <Vector2> retVal = new List <Vector2>(); foreach (SearchPoint sp in path) { retVal.Add(sp.position); } return(retVal); }