int iGridSizeX, iGridSizeY; //Size of the Grid in Array units. private void Start() //Ran once the program starts { fNodeDiameter = fNodeRadius * 2; //Double the radius to get diameter iGridSizeX = Mathf.RoundToInt(vGridWorldSize.x / fNodeDiameter); //Divide the grids world co-ordinates by the diameter to get the size of the graph in array units. iGridSizeY = Mathf.RoundToInt(vGridWorldSize.y / fNodeDiameter); //Divide the grids world co-ordinates by the diameter to get the size of the graph in array units. CreateGrid(); //Draw the grid DijkstraTile[,] dijtraGrid = DijkstraGrid.generateDijkstraGrid(this.NodeArray, new Vector2Int(iGridSizeX, iGridSizeY), NodeFromWorldPoint(StartPosition.position)); DijkstraTile[,] flowFieldGrid = FlowFieldGrid.generateFlowField(new Vector2Int(iGridSizeX, iGridSizeY), dijtraGrid); }
// Start is called before the first frame update void Awake() { subGrid = new custom_grid(); subGrid.cellSize = 5.0f; superGrid = new custom_grid(); superGrid.cellSize = 50.0f; destination = transform.position; Path = new Stack <Pair <int, int> >(); //initialize empty path djgrid = new DijkstraGrid(); //dijkstra grid is created during flowfield generation, it's used to determine if a cell is blocked or not }