I'm trying to create a voxel-style cone shape in C#. I've got the cone building using cubes, but can't work out how to only build the outer layer (make it hollow) rather than build a solid cone as shown in the pic.

[![voxel cone.](https://i.stack.imgur.com/jmH8d.png)](https://i.stack.imgur.com/jmH8d.png)
The code so far (Edited from someone else's script)

```
// Create a cone made of cubes. Can be called at runtime
public void MakeVoxelCone()
{
    for (int currentLength = 0; currentLength < maxLength; currentLength++)
        MakeNewLayer(currentLength);
}

// Make a new layer of cubes on the cone
private void MakeNewLayer(int currentLength)
{
    center = new Vector3(0, currentLength, 0);
    for (int x = -currentLength; x < currentLength; x++)
    {
        for (int z = -currentLength; z < currentLength; z++)
        {
            // Set position to spawn cube
            Vector3 pos = new Vector3(x, currentLength, z);

            // The distance to the center of the cone at currentLength point
            float distanceToMiddle = Vector3.Distance(pos, center);

            // Create another layer of the hollow cone
            if (distanceToMiddle < currentLength)
            {
                // Add all cubes to a List array
                Cubes.Add(MakeCube(pos));
            }
        }
    }
}

// Create the cube and set its properties
private GameObject MakeCube(Vector3 position)
{
    GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
    cube.GetComponent<Renderer>().material.color = Color.blue;
    if (!AddCollider)
        Destroy(cube.GetComponent<BoxCollider>());
    cube.transform.position = position;
    cube.transform.parent = transform;
    cube.name = "cube [" + position.y + "-" + position.x + "," + position.z + "]";

    return cube;
}

```

I think its probably simple, but cant figure it out.
Maybe something about the `if (distanceToMiddle < currentLength)` part, but swapping `<` for `==` breaks the whole shape.

@Jax297 `>= (currentLength-1)` Closer, but not correct just yet. Now its a pyramid with a cone cut out.
[![enter image description here](https://i.stack.imgur.com/cLwJr.png)](https://i.stack.imgur.com/cLwJr.png)