I apologize if this makes you slap your face in agony (im very new to C# and Unity). I’ve recently started a basic terrain generator however the output I get from the Mathf.PerlinNoise function (when used to instantiate my grass block) keeps making the exact same hills in a random order and then cutting to a plateau. I’ve given it a seed and allows it to randomly generate however the output always involves the same noise/shapes.
My Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class generator : MonoBehaviour
{
public GameObject Dirt;
void Start()
{
int width = 1000;
long seed = seedGen(); // generate random seed
generate(width, height, seed); // generate terrain
}
private void generate(int width, int height, long seed)
{
float t = 0;
for (int x = 0; x <= width; x++)
{
float noise = Mathf.PerlinNoise(t + seed, seed);
noise = Mathf.Round(noise * 100);
Instantiate(Grass, new Vector2(x, noise), Quaternion.identity);
t += (float)0.01;
}
}
public int seedGen()
{
int seed = Random.Range(0, 10000);
return seed;
}
}
Plateau:
Similar or Identical Generation:
My goal is to develop generation similar to Terraria’s however I can’t find enough documentation or talk of this without completely developing a custom perlin noise function (something I can’t for the life of me understand). How am I able to alter this code to generate better terrain using Mathf.PerlinNoise?