[BEGINNER] Generating Terrain with Perlin noise flat and nothing happens ?


the Script below should make a cube, and then copy it while setting the depth according to the perlin noise, and always go +1 along both z and x axis. However, when I run the script, the cubes are all on the same heigth.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class terrainGen : MonoBehaviour {
public terrainGen terrain;
private GameObject cube;
private int seed = 4864842;
private float heigth;

 // Use this for initialization
 void Start () {
     cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
     editTerrain ();
     heigth = 0.0f;

 void editTerrain()
     int xResolution = 50;
     int zResolution = 50;
     //float[,] heights;

     for(int z=0; z <= zResolution ; z++)
         for(int x=0; x <= xResolution ; x++)
             float y = Mathf.PerlinNoise (heigth+seed, 0.0f);
             Debug.Log (heigth);
             heigth = heigth + 100f;
             Instantiate(cube, new Vector3(x, y, z),Quaternion.identity);


Hi !

Just call Mathf.PerlinNoise with a different seed. In your exemple it is always 4864842. You can use time for exemple as seed.