// Update is called once per frame void Update() { foreach (var o in obstacles) { Vector2Int index = grid.GetIndexFromGridPosition(o.transform.position); var neighbors = grid.GetNeightborAStar(index); foreach (var n in neighbors) { if (n.distance == -2) { continue; } n.distance = -1; } grid.tiles[index.x, index.y].distance = -2; } grid.UpdateFlowField(target.position); index = grid.GetIndexFromGridPosition(transform.position); if (pathFind == true) { pathFind = false; } }