C# 尝试创建3D体素地形,我尝试多次创建随机种子,而不是相同的种子

C# 尝试创建3D体素地形,我尝试多次创建随机种子,而不是相同的种子,c#,random,3d,perlin-noise,voxel,C#,Random,3d,Perlin Noise,Voxel,我试图找出如何在C#中随机化我的柏林噪声,但找不到一种方法来使用我目前拥有的代码。这是我的密码: using System.Collections; using System.Collections.Generic; using UnityEngine; public class PerlinCubeGenScript01 : MonoBehaviour { public float perlinNoise = 0f; public float refinement = 0f; public

我试图找出如何在C#中随机化我的柏林噪声,但找不到一种方法来使用我目前拥有的代码。这是我的密码:

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

public class PerlinCubeGenScript01 : MonoBehaviour {

public float perlinNoise = 0f;
public float refinement = 0f;
public int multiplier = 0;
public int cubes = 0;
public float darkness;


void Start () {


    for (int i = 0; i < cubes; i++) {

        for (int j = 0; j < cubes; j++) {

            perlinNoise = Mathf.PerlinNoise(i * refinement, j * refinement);
            GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
            go.transform.position = new Vector3(i, Mathf.Round(perlinNoise * multiplier), j);

            int cubeY = (int) Mathf.Round(perlinNoise * multiplier);
            Debug.Log(cubeY);

            go.GetComponent<Renderer>().material.color = new Color(1, 1, 1, 0f);

        }
    }
}

void Update () {

}
}
使用系统集合;
使用System.Collections.Generic;
使用UnityEngine;
公共类PerlinCubeGenScript01:单一行为{
公共浮筒perlinNoise=0f;
公共浮点求精=0f;
公共整数乘数=0;
公共整数立方=0;
公众漂浮在黑暗中;
无效开始(){
对于(int i=0;i
只要柏林噪声函数允许您拾取二维空间中的任意点,为什么不简单地使用随机数作为种子并从那里开始拾取点

void Start () {

    Random rnd = new Random();
    int seed = rnd.Next(Int32.MinValue, Int32.MaxValue);

    for (int i = 0; i < cubes; i++) {

        for (int j = 0; j < cubes; j++) {

            perlinNoise = Mathf.PerlinNoise(seed + (i * refinement), seed + (j * refinement));  
            // Note that if refinement never changes you are always picking the same point
            GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
            go.transform.position = new Vector3(i, Mathf.Round(perlinNoise * multiplier), j);

            int cubeY = (int) Mathf.Round(perlinNoise * multiplier);
            Debug.Log(cubeY);

            go.GetComponent<Renderer>().material.color = new Color(1, 1, 1, 0f);

        }
    }
}
void Start(){
随机rnd=新随机();
int seed=rnd.Next(Int32.MinValue,Int32.MaxValue);
对于(int i=0;i
您不是每次都选择
0,0
点吗?您没有更改
细化
变量。。。