![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | mustafamax |
I want to create terrain using Grid Map
I used this code to generate terrain
But I didn’t get the thing expected
Are there other solutions?
thank you
Example code
extends GridMap
func _ready():
var noise = OpenSimplexNoise.new()
noise.seed = rand_range(5, 10)
noise.octaves = 4
noise.period = 20.0
noise.persistence = 0.8
var width = 50
var height = 50
for x in width:
for y in height:
for z in width:
set_cell_item(x, y, z, 0)
var yR = floor(noise.get_noise_3d(x, y, z))
if y > 2:
set_cell_item(x, y, z, yR)
An illustration of what the code produces above
After modifying the code, I got this result
extends GridMap
func _ready():
var width = 100
var height = 50
var noise = OpenSimplexNoise.new()
noise.seed = rand_range(1, height)
noise.octaves = 0
noise.period = 30
noise.persistence = 10
for x in width:
for y in height:
for z in width:
var yR = noise.get_noise_3d(x, y, z)
set_cell_item(x, floor(yR*10), z, 0)
The result is rather acceptable
But welcome to amend
mustafamax | 2021-04-13 09:35