# Perlin Noise Question.

Hi, so I am trying to generate a Minecraft-like terrain using Mathf.PerlinNoise. It works, however, whenever I restart the game I get the same terrain. How do I actually randomize the “image” of the perlin noise. Do you understand what I mean? Thank you! Also, if it helps, here is the code I use.

``````var chunkWidth: int = 16;
var chunkDepth: int = -5;
var cubeGameObject: GameObject;
var terrainHeight: int = 1;

function Start ()
{
createChunk();
}

function Update ()
{

}

function createChunk()
{
var currentX: int = 1;
var currentZ: int = 1;

for(var x = 0; x < chunkWidth; x++)
{
currentX = x;
for(var z = 0; z < chunkWidth; z++)
{
currentZ = z;

var generatedCube:GameObject;
generatedCube = Instantiate(cubeGameObject, Vector3(currentX, Mathf.Round(Mathf.PerlinNoise(currentX * 0.1, currentZ * 0.1 ) * terrainHeight), currentZ), Quaternion.Euler(0,0,0));

var blocksAdded: int = 1;
for(var d = generatedCube.transform.position.y; d > chunkDepth; d--)
{
Instantiate(cubeGameObject, generatedCube.transform.position - Vector3(0,blocksAdded,0), Quaternion.Euler(0,0,0) );
blocksAdded++;
}
}
}

Debug.Log("A Chunk has been created!");
}
``````

Add random offsets (calculated once in Start()) to the x and y:

``````Mathf.PerlinNoise(randX + currentX * 0.1, randY + currentZ * 0.1 )
``````