Unity3d C#统一生成器世界六边形
我做了一些改变。 1°为了暂时简化代码,我使用了方框。 2°我正在使用math.PerlinNoise练习,但有些网格远离其他网格。 3°我需要建造带有砌块的地块,但它们是圆形的。 到目前为止,我已经能够在这里做到这一点,我将留下代码和图像,试图描述我的问题Unity3d C#统一生成器世界六边形,unity3d,random,game-engine,Unity3d,Random,Game Engine,我做了一些改变。 1°为了暂时简化代码,我使用了方框。 2°我正在使用math.PerlinNoise练习,但有些网格远离其他网格。 3°我需要建造带有砌块的地块,但它们是圆形的。 到目前为止,我已经能够在这里做到这一点,我将留下代码和图像,试图描述我的问题 public void Start() { myPos=this.transform.position; CreateMap(CreateMapMatrix(100,40),100,40); } 公共向量3[,]CreateMapMat
public void Start()
{
myPos=this.transform.position;
CreateMap(CreateMapMatrix(100,40),100,40);
}
公共向量3[,]CreateMapMatrix(整数宽度,整数高度)
{
matrixMap=新矢量3[宽度、高度];
对于(int x=0;x
您应该尝试使用柏林噪声来完成世界生成。像Minecraft和Raft这样的游戏会利用它
我听不懂这里的问题。对不起,我说的是英语,我是巴西人。我需要制定一种方法,让世界上这一代的无孔平台,我的世界是崎岖不平的,通道非常狭窄。一个粗略的建议是,第二次通过你的世界一代,以清除任何次要的不良特征。我能够创造一些东西,我看了一眼,明白了一点,但结果并没有完全符合我的需要。因为我需要的是,这些区块不能一个接一个地连在一起,没有空间。我不理解你的评论。你能不能说得更详细一点?我需要做一个地形发生器,我正在尝试实现PerlinNoise,但没有结果。这个怎么样?
public void Start()
{
myPos = this.transform.position;
CreateMap(CreateMapMatrix(100, 40),100, 40);
}
public Vector3[,] CreateMapMatrix(int width, int height)
{
matrixMap = new Vector3[width, height];
for (int x = 0; x < width; x++)
{
for (int z = 0; z < height; z++)
{
float h = Mathf.PerlinNoise((seed + myPos.x + x) / width,
(myPos.z + z) / height) * x;
h = Mathf.Floor(h);
matrixMap[x, z] = new Vector3(h, 0, z);
}
}
return matrixMap;
}
void CreateMap(Vector3[,] pos, int width, int height)
{
for (int x = 0; x < width; x++)
{
for (int z = 0; z < height; z++)
{
GameObject Obj = Instantiate(hexTransform[0]);
Obj.transform.position = pos[x,z];
}
}
}