0 votes


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():
noise = OpenSimplexNoise.new()
noise.seed = randi()
noise.octaves = 3
noise.period = 18
noise.persistence = 0.8

func chunk(chunkwidth,chunklength,chunkdepth):
for x in chunk
for y in chunkdepth:
for z in chunk
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
final = Blocks.empty()
for num in range(0,z):
map.setcellitem(x,y,z + nextchunkcoord.z,final)
nextchunkcoord.z += chunk_length

in Engine by (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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.