void GenerateCave() { CaveGenerator caveGenerator = terrain.GetComponent <CaveGenerator>(); caveGenerator.Generate(); CaveGenerator.Point?point = caveGenerator.FindNearestSpace(caveGenerator.currentMap, new CaveGenerator.Point(0, 0)); //Find nearest clear point to bottom corner of map if (point.HasValue) { player.position = new Vector3(point.Value.x, point.Value.y, player.position.z) + terrain.position; //Terrain transform may not be at zero so map coordinates will be offset by its position } }