void Scan(bool argCubeMeshOff) { points = new List <GameObject>(); Queue <GameObject> toVisit = new Queue <GameObject>(); // create the first point and add it to the gridpoint list and the toVisit list Vector3 startPosition = new Vector3(transform.position.x, transform.position.y + gridHeight, transform.position.z); GameObject point = Instantiate(gridPoint, startPosition, Quaternion.identity) as GameObject; point.transform.parent = mapObject.transform; GridPoint gp = point.GetComponent <GridPoint>(); segmentDistance = gp.GetGpSegmentDist(); if (argCubeMeshOff) { gp.turnCubeMeshOff(); } firstPoint = point; points.Add(point); toVisit.Enqueue(point); // while there are points in the queue, tell each one to scan for new points while (toVisit.Count > 0) { GameObject p = toVisit.Dequeue(); p.GetComponent <GridPoint>().Scan(points, toVisit, mapObject); } // remove points that are too close to spatial mesh //CheckBounds(); //remove any points that are not connected to root node (firstPoint) //CheckConnectivity(); GameObject.Find("GameManager").GetComponent <GameManager>().GridBuilt(this); }