Here goes,
I have created a script that when applied to a plane it creates random hills and valleys as it should. Now here lies my question. How do I make the end points stop at 0 naturally. For example I would have a plane and in the center would be random hills and valleys but the edges would be flat. Here is my Perlin Noise Script;
public float power = 3.0f;
public float scale = 1.0f;
private Vector2 v2SampleStart = new Vector2(0f, 0f);
void Start ()
{
Noise ();
}
void Update () {
if (Input.GetKeyDown (KeyCode.Space))
{
v2SampleStart = new Vector2(Random.Range (0.0f, 100.0f), Random.Range (0.0f, 100.0f));
Noise();
}
}
void Noise() {
MeshFilter mf = GetComponent<MeshFilter>();
Vector3[] vertices = mf.mesh.vertices;
for (int i = 0; i < vertices.Length; i++)
{
float xCoord = v2SampleStart.x + vertices_.x * scale;_
float yCoord = v2SampleStart.y + vertices_.z * scale;
vertices.y = (Mathf.PerlinNoise (xCoord, yCoord) - 0.5f) * power;
* }
mf.mesh.vertices = vertices;
mf.mesh.RecalculateBounds();
mf.mesh.RecalculateNormals();
}*
Thanks in advanced!_