# Perlin Noise Implementation

This may sound like a noob question, but I have been looking for a solution for a few days now. I have written a randomized map generator (it generates a map in real time). I need to be able to give each point a y value (otherwise it is flat). So, here is my question; how do I generate a perlin noise heightmap, and get the height of one pixel at a time?

``````var SomeSortOfPerlinNoise = Perlin noise (x_var in for loop, y_var in for loop);

vertices[value_on] = Vector3(x_var, SomeSortOfPerlinNoise, 0.0f),y_var);
``````

I just need set the value of SomeSortOfPerlinNoise, and my map generator will work. Any suggestions?

Unity has built-in Perlin Noise support: Mathf.PerlinNoise.

``````for(x = 0; x <worldSizeX; x++) {
for(z = 0; z < worldSizeZ; z++) {
float height;

height = Mathf.PerlinNoise(x, z) * 10f;
}
}
``````

Your scale is not too low it’s too high. PerlinNoise doesn’t use big numbers it works in low numbers… from what I can tell.

I had the same problem today and diving by 10 made it extra jagged. dividing by 1000 made it a big slow wave. Still not what I’m looking for, but the answer is PerlinNoise, you and I just don’t fully understand it ;p