Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

My Noise for terrain isn't efficient, Any help?

Asked by
Coder_1 27
4 years ago
Edited 4 years ago
01for x = 1, 100 do
02    for z = 1, 100 do
03        local height = (math.noise(x / 20, z / 20) + 2) * 50
04        local p = Instance.new("Part", workspace)
05        p.Locked, p.Anchored = true, true
06        p.Size = Vector3.new(4, height, 4)
07        p.CFrame = CFrame.new(4 * x, height / 2, 4 * z)
08        wait()
09    end
10end

This is not efficient at all and take so long to load in. Is there anyway to make it load in chunks similar to minecraft and only load in top blocks and load in other filler blocks if you go into a cave. I searched online on documentation on math.noise but i don't see anything on it. People just say its a math function.

0
you can remove the wait() thast already quite some time less VerdommeMan 1479 — 4y
0
rn ur losing 300s bc of it (0.03*100*100) if wait is by default 0.03 VerdommeMan 1479 — 4y
0
Ok but it still extremely laggy Coder_1 27 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Instead of just generating the whole thing(which will take a long time), I recommend you generate chunks around where all the players are, which is what Minecraft does.

I found this script off the devforum that does exactly what you want, note that it contains some ugly stuff like parenting before changing the properties, but it should do:

01local Players = game:GetService("Players")
02 
03------------------------------------------------------------------------------------------------------------------------------------------------
04 
05local BASE_HEIGHT       = 10                -- The main height factor for the terrain.
06local CHUNK_SCALE       = 1                 -- The grid scale for terrain generation. Should be kept relatively low if used in real-time.
07local RENDER_DISTANCE   = 25                    -- The length/width of chunks in voxels that should be around the player at all times
08local X_SCALE           = 90 / 4            -- How much we should strech the X scale of the generation noise
09local Z_SCALE           = 90 / 4            -- How much we should strech the Z scale of the generation noise
10local GENERATION_SEED   = math.random()     -- Seed for determining the main height map of the terrain.
11 
12------------------------------------------------------------------------------------------------------------------------------------------------
13 
14local chunks = {}
15 
View all 79 lines...

Hope this helped

Ad

Answer this question