public void BreakWall(Vector3 point) { Point cell = cellGrid.GetIdxFromPos(point); int width = hiResGrid.GetLength(0); int height = hiResGrid.GetLength(1); if (cell.x >= 0 && cell.y >= 0 && cell.x < width && cell.y < height) { hiResGrid[cell.x, cell.y].visited = true; emptySpaces.Add(cellGrid.Grid[cell.x, cell.y]); // Regenerate mesh Destroy(mesh); mesh = MeshGenerator.GenerateMesh(hiResGrid); GetComponent <MeshFilter>().mesh = mesh; GetComponent <MeshCollider>().sharedMesh = mesh; } }