private void Start() { //Setup the configuration. You only need to set the values you want different from the defaults that you can see on the GridConfig class. var gridCfg = new GridConfig { cellSize = 2f, generateHeightmap = true, heightLookupType = HeightLookupType.QuadTree, heightLookupMaxDepth = 5, lowerBoundary = 1f, upperBoundary = 10f, obstacleSensitivityRange = 0.5f, sizeX = 16, sizeZ = 16, subSectionsX = 2, subSectionsZ = 2, subSectionsCellOverlap = 2, origin = this.gridHost.transform.position }; //Create the grid instance var grid = GridComponent.Create(this.gridHost, gridCfg); //Initialize the grid grid.Initialize(10, g => { Debug.Log("Initialization Done"); }); }
private void BuildGrids(Bounds b) { if (gridSize % cellSize != 0 || gridSize % cellSize != 0) { Debug.LogError("Grid Width and Grid Height must be a multiple of Cell Size"); } var gridColumns = Mathf.FloorToInt(b.size.x / gridSize); var gridRows = Mathf.FloorToInt(b.size.z / gridSize); var baseOrigin = b.min + new Vector3(gridSize * .5f, b.size.y, gridSize * .5f); var offset = Vector3.zero; var cfg = new GridConfig { cellSize = this.cellSize, sizeX = (int)(gridSize / cellSize), sizeZ = (int)(gridSize / cellSize), automaticConnections = true }; for (int x = 0; x < gridColumns; x++) { for (int z = 0; z < gridRows; z++) { offset.x = x * gridSize; offset.z = z * gridSize; cfg.origin = baseOrigin + offset; GridComponent.Create(this.gridHost, cfg); } } }
private void Start() { var go = this.gameObject; //Setup the configuration. You only need to set the values you want different from the defaults that you can see on the GridConfig class. var gridCfg = new GridConfig { cellSize = 1f, sizeX = 32, sizeZ = 32, origin = go.transform.position, obstacleAndGroundDetection = ColliderDetectionMode.Custom, obstacleAndGroundDetector = OddBlockDetector.instance }; //Create the grid instance var grid = GridComponent.Create(go, gridCfg); //Initialize the grid grid.Initialize(10, g => { Debug.Log("Initialization Done"); }); }