// Update is called once per frame void Update() { float n1 = noise.FractalNoise1D(transform.position.x, octNum, frq, amp); float n2 = noise.FractalNoise1D(transform.position.x, octNum, frq + 10, amp); //float t = noise.FractalNoise1D(transform.position.x,octNum+2,frq,amp); Vector2 offset = new Vector2(transform.position.x + 0.1f, n1 + n2); transform.position = offset; }
// Update is called once per frame void Update() { renderer.SetVertexCount(50); for (int i = 0; i < 50; i++) { float n1 = noise.FractalNoise1D(i, octaves, frequency, amplitude); float n2 = noise.FractalNoise1D(i, octaves, frequency, amplitude + offsetAmp); this.renderer.SetPosition(i, new Vector2(i, n1 + n2)); } }
void GenerateSurface() { InstallBiomes(); float dA = BHLenght / Radius; //угол кусочка поверхности длиной в метр(по горизонтальному проложению) int step = 0; int capacity = Mathf.CeilToInt(2 * Mathf.PI / dA); Vector2[] path = new Vector2[capacity + 1]; rend.SetVertexCount(capacity + 1); //Generation PerlinNoise noise = new PerlinNoise(Random.Range(-999999, 999999)); if (currentBiome == null) { currentBiome = BiomesList[0]; } if (lastBiome == null) { lastBiome = currentBiome; } int len = currentBiome.lenght; int transitionLenght = 0; float currentLenght = 0; Camera.main.transform.position = new Vector3(0, Radius, Camera.main.transform.position.z); int transHeight = 0; for (float angle = 0; angle <= Mathf.PI * 2 + dA; angle += dA) { Vector2 dirVector = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)); Vector2 point; float delta; delta = noise.FractalNoise1D(step, currentBiome.octaves, currentBiome.frequency, currentBiome.height); currentLenght += delta; point = dirVector * (Radius + currentLenght); if (len <= 0) { lastBiome = currentBiome; currentBiome = BiomesList[Random.Range(0, BiomesList.Count)]; len = currentBiome.lenght; transitionLenght = 50; } path[step] = point; rend.SetPosition(step, point); ////////////////////////////// len--; step++; Debug.Log(angle); } coll.SetPath(0, path); }
void Generate() { Vector2[] points = new Vector2[lenght]; for (int i = 0; i < lenght; i++) { float h = noise.FractalNoise1D(i, oct, frq, amp); points[i] = new Vector2(i, h); } this.collider.points = points; }