1
\$\begingroup\$

I am trying to generate terrain using perlin noise however the terrain being generated is a plateau. Here is the code that I'm using:

var xlength = 65.0;
var ylength = 65.0;
var scale = 4.1f;
var heights = new float[xlength, ylength];
function Start () {
    for (var i = 0; i < xlength; i++)
        for (var j = 0; j < ylength;j++)
            heights[i,j] = Mathf.PerlinNoise(Time.time * i / xlength * scale/1000,Time.time * j / ylength * scale/1000)*i*j;
    gameObject.GetComponent(Terrain).terrainData.SetHeights(0,0,heights);
} 

What am I doing wrong here?

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

If you want seamless 'chunks', then you should evenly sample between whole integers.

 heights[i,j] = Mathf.PerlinNoise(i / xlength, j / ylength);

And resulting data must be between 0..1 (so don't scale it here).

heights: Array of heightmap samples to set (values range from 0 to 1, array indexed as [y,x]). - Unity Documentation: TerrainData.SetHeights

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .