0 votes

Output

Hi, I am trying to make minecraft using titlemap and OpensimplexNoise[Procedural Generation ] , but I am getting the dirt blocks above the Grass blocks and I not able to generate terrain.

Here's my source code :

extends Spatial

enum Blocks {Dirt,Grass,Stone}
var groundsize = Vector3(10,10,10)
var next
chunk_coord = Vector3(0,0,0)
var noise
onready var map = $World/GridMap

func ready():
randomize()
noise = OpenSimplexNoise.new()
noise.seed = randi()
noise.octaves = 3
noise.period = 18
noise.persistence = 0.8
chunk(ground
size.x,groundsize.y,groundsize.z)

func chunk(chunkwidth,chunklength,chunkdepth):
for x in chunk
width:
for y in chunkdepth:
for z in chunk
length:
var final = 0
var a = noise.getnoise3d(x,y,z + nextchunkcoord.z)
#var a = noise.getnoise1d(y)
if a < 0.02:
final = Blocks.Dirt
elif a >=0.02 and a < 0.4 :
final = Blocks.Grass
elif a >=0.4 and a < 0.7:
final = Blocks.Stone
else:
final = Blocks.empty()
for num in range(0,z):
map.setcellitem(x,y,z + nextchunkcoord.z,final)
nextchunkcoord.z += chunk_length

asked Jun 18 in Projects by Tarun (14 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.