Always same result from Mathf.PerlinNoise()

Hi,

I’m having some trouble using the Perlin Noise generator.

using UnityEngine;
using System.Collections;

public class PerlinTest : MonoBehaviour {
	private float inNum;
	
	// Use this for initialization
	void Start () {
		inNum = 0.0f;
	}
	
	// Update is called once per frame
	void Update () {
		Debug.Log(inNum + ": " + Mathf.PerlinNoise(inNum,0.0f));
		inNum = inNum + 100.0f;
	}
}

I keep getting the same number. What am I doing wrong?
Thanks!

Change line 15 to the following:

inNum = inNum + 0.01f;

I ran into this problem the first time I used PerlinNoise(). It appears that the results are mod 1.0. So you will have this issue if you use 1.0 or 100.0. But change the numbers to 1.01 or 100.1 and you will not longer get a repeating number. But such large numbers will not give you the smooth transitions either.

The Perlin Noise is getting value starting at the same point each time. The function is a string of the wave based values. So you are going to end up traversing the same landscape every time.

So you need to seed the function to force it to start ad different point.

using UnityEngine;
using System.Collections;

public class PerlinTest : MonoBehaviour {
	private float inNum;
	private int seed = (int)Network.time * 10;

	// Use this for initialization
	void Start () {
		inNum = 0.0f;
	}

	// Update is called once per frame
	void Update () {
		Debug.Log(inNum + ": " + Mathf.PerlinNoise(inNum + seed,0.0f));
		inNum = inNum + 100.0f;
	}
}