Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would you do "Minecraft" like terrain generation?

I want to make terrain generation like in minecraft with places where there is flat surface and places where there are mountains. However while i was using perlin noise and looked at all roblox terrain generation examples i noticed that you can only make it either have tons of mountains or just a flat surface. I looked up on google and it said that i need to use multiple octaves but i dont know how to do that in roblox. Anyone knows how to do it?

1 answer

This is a very complex system. To perform this, you would have to have algorythms that change the frequency of the generation system. Here's an example from the wiki:

local seed = math.random()
local width = 200
local length = 200
local amplitude = 20
local frequency = 25
 
for x = -width/2,width/2 do
	for z = -length/2,length/2 do
		local y = (math.noise(seed,x/frequency,z/frequency) * (amplitude/2)) + (amplitude/2)
		workspace.Terrain:FillBlock(CFrame.new(x*4,y*2,z*4),Vector3.new(4,y*4,4),Enum.Material.Grass)
	end
end
 

Now, to make the different frequencies, we can do this:

amplitude = amplitude + math.random(-1.0,1.0)
frequency = frequency + math.random(-1.0,1.0)

And that makes:

local seed = math.random()
local width = 200
local length = 200
local amplitude = 20
local frequency = 25
 
for x = -width/2,width/2 do
	for z = -length/2,length/2 do
		local y = (math.noise(seed,x/frequency,z/frequency) * (amplitude/2)) + (amplitude/2)
		amplitude = amplitude + math.random(-1.0,1.0)
		frequency = frequency + math.random(-1.0,1.0)
		workspace.Terrain:FillBlock(CFrame.new(x*4,y*2,z*4),Vector3.new(4,y*4,4),Enum.Material.Grass)
	end
end

Hope this helps!

6 comments

0

It does fine but after 1 or 2 seconds it stops and gives an error : Extents cannot be empty?

0

It seems to work if you add a wait() after each fillblock, but this means the terrain takes forever to generate

0

Still the landshape looks weird

0

This is a very wide and broad topic. You cannot just ask one question and get an answer that will match all your needs. This answer gives the framework for which to begin, but I suggest you do your own research on this topic.

0

I already looked through all roblox pages about it and all non roblox. Even if i found a good one that described everything i couldnt think of how to implent it in roblox.Also i didnt ask for the whole thing, I asked how could i do octaves since i already have a working script that just generates either plains or mountains.

This discussion is preserved as it was. New answers, comments, and votes are closed.