Exemplo n.º 1
0
    private void Start()
    {
        if (!cell_prefab)
        {
            return;
        }

        Vector2 axial          = new Vector2();
        int     half_grid_size = grid_size / 2;

        for (int x = -half_grid_size; x < half_grid_size; x++)
        {
            axial.x = x;
            for (int y = -half_grid_size; y < half_grid_size; y++)
            {
                axial.y = y;
                Vector3 cartesian = HexGrid.AxialToCartesian(axial, cell_size);

                Ray        ray = new Ray(cartesian.WithY(100.0f), Vector3.down);
                RaycastHit hit;
                if (!Physics.Raycast(ray, out hit))
                {
                    GameObject.Instantiate(cell_prefab, cartesian, Quaternion.identity, transform);
                }
            }
        }
    }