//creates 3d structure of a maze private void InitMaze() { transform.position = new Vector3(0, 0, 0); //set maze position to the origine mazeCells = new MazeCell[mazeHeight][, ]; // i follows x axis // j follows z axis for (int t = 0; t < mazeHeight; t++) { mazeCells[t] = new MazeCell[mazeSize, mazeSize]; //initialize a floor //instantiate each cell on a floor. for (int i = 0; i < mazeSize; i++) { for (int j = 0; j < mazeSize; j++) { mazeCells[t][i, j] = new MazeCell(); mazeCells[t][i, j].coordinates = new Vector3Int(i, t, j); } } PrimsMazeGenerator.run(mazeCells[t], mazeSize); //create the maze. for (int i = 0; i < mazeSize; i++) { for (int j = 0; j < mazeSize; j++) { mazeCells[t][i, j].visited = false; } } //reset all visited to false, for BFS } InitializeCollider(); }