# Bug Math.PerlinNoise ? Simple generator

I’m trying to create a small world generator with cubes, but my world only works with the x and z axis.
I need to round or even distort some cubes, but they need to stay aligned and always lean against each other.

What is going on

What i need to create

``````public void Start()
{
myPos = this.transform.position;
CreateMap(CreateMapMatrix(100, 40),100, 40);

}

public Vector3[,] CreateMapMatrix(int width, int height)
{
matrixMap = new Vector3[width, height];

for (int x = 0; x < width; x++)
{
for (int z = 0; z < height; z++)
{

float h = Mathf.PerlinNoise((seed + myPos.x + x) / width,
(myPos.z + z) / height) * x;

h = Mathf.Floor(h);

matrixMap[x, z] = new Vector3(h, 0, z);
}

}

return matrixMap;

}

void CreateMap(Vector3[,] pos, int width, int height)
{
for (int x = 0; x < width; x++)
{
for (int z = 0; z < height; z++)
{
GameObject Obj = Instantiate(hexTransform[0]);
Obj.transform.position = pos[x,z];

}
}
}
``````

Thank for all

Alrighty time to dig out those good ole’ math skills!

So the problem here is you want it in 3D but you have not got the negative value for x and z.
Square roots give both positive and negative results.

If you want a perfect circle you might do something like this:

``````x = new Vector2(+Mathf.sqrt(y^2-r^2), -Mathf.sqrt(y^2-r^2));
z = new Vector2(+Mathf.sqrt(x^2-r^2), -Mathf.sqrt(x^2-r^2));
``````

Also this is the general section not the help section!