EVERYTHING WORKS, i just need help on how i would go about interpolating the heightmap is the biome changes, because whenever the biome changes, the height multiplyer does too, but not smoothly, so when i reach a more bumpy biome, there is a huge wall of terrain in the way instead of a slope that gradients
Full code in server script service:
-- code snippet taken and modified from http://bit.ly/2D2lF3O math.randomseed(os.time()) local baseHeight = 50 -- The main height factor for the terrain. local chunkScale = 1 -- The grid scale for terrain generation. Should be kept relatively low if used in real-time. local renderDist = 320/4 -- The length/width of chunks in voxels that should be around the player at all times local xScale = 90/4 -- How much we should strech the X scale of the generation noise local zScale = 90/4 -- How much we should strech the Z scale of the generation noise local generationSeed = math.random() -- Seed for determining the main height map of the terrain. local biomes = require(script.Biomes) local biome = 1 local spawnbiome = 1 ------------------------------------------------------------------------------------------------------------------------------------------------ biome = spawnbiome local chunks = {} function chunkExists(chunkX,chunkZ) if not chunks[chunkX] then chunks[chunkX] = {} end return chunks[chunkX][chunkZ] end function mountLayer(x,heightY,z) local begY = -baseHeight local endY = heightY --workspace.Terrain:FillBlock(CFrame.new(x*4+2, (begY+endY)*4/2, z*4+2), Vector3.new(4, (endY-begY)*4, 4), material) if endY > 5 then workspace.Terrain:FillBlock(CFrame.new(x*4+2, 0, z*4+2), Vector3.new(4, biomes[biome].WallSize*2, 4), biomes[biome].WallMaterial) else workspace.Terrain:FillBlock(CFrame.new(x*4+2, 0, z*4+2), Vector3.new(4, (endY-begY)*biomes[biome].HeightMultiplyer+biomes[biome].FloorThickness, 4), biomes[biome].FloorMaterial) end if biomes[biome].Caves then workspace.Terrain:FillBlock(CFrame.new(x*4+2, biomes[biome].WallSize, z*4+2), Vector3.new(4, (endY-begY)*biomes[biome].HeightMultiplyer, 4), biomes[biome].CaveMaterial) end workspace.Terrain:FillBlock(CFrame.new(x*4+2, -(biomes[biome].WallSize), z*4+2), Vector3.new(4, 4, 4), biomes[biome].UnderMaterial) end function determineBiome(magnitude) local biomechosen for i=1,#biomes do if biomes[i].Level >= magnitude then biomechosen = i end if magnitude < biomes[i].Level then return biomechosen-1 end end end function makeChunk(chunkX,chunkZ,magnitude) local rootPos = Vector3.new(chunkX*chunkScale,0,chunkZ*chunkScale) chunks[chunkX][chunkZ] = true -- Acknowledge the chunk's existance. for x = 0,chunkScale-1 do for z = 0,chunkScale-1 do local cx = (chunkX*chunkScale) + x local cz = (chunkZ*chunkScale) + z local noise = math.noise(generationSeed,cx/xScale,cz/zScale) local cy = noise*baseHeight biome = determineBiome(magnitude) mountLayer(cx,cy,cz) end end end function checkSurroundings(location) local chunkX,chunkZ = math.floor(location.X/4/chunkScale),math.floor(location.Z/4/chunkScale) local range = math.max(1,renderDist/chunkScale) for x = -range,range do for z = -range,range do local cx,cz = chunkX + x,chunkZ + z if not chunkExists(cx,cz) then makeChunk(cx,cz,math.floor(location.magnitude/100)) end end end end while true do for _,player in pairs(game.Players:GetPlayers()) do if player.Character then local torso = player.Character:FindFirstChild("Head") if torso then checkSurroundings(torso.Position) end end end wait(0.2) end
there is a module script in the main script called "Biomes" as referenced above:
local m = { { Name = "Plains", HeightMultiplyer = 1, WallMaterial = Enum.Material.Rock, FloorMaterial = Enum.Material.Grass, Level = 0, Caves = false, CaveMaterial = nil, WallSize = 250, FloorThickness = 4, UnderMaterial = Enum.Material.Air }, { Name = "Land Of Dead", HeightMultiplyer = 3, WallMaterial = Enum.Material.Rock, FloorMaterial = Enum.Material.Ground, Level = 20, Caves = false, CaveMaterial = nil, WallSize = 250, FloorThickness = 4, UnderMaterial = Enum.Material.Air }, { Name = "Desert", HeightMultiplyer = 0.5, WallMaterial = Enum.Material.Limestone, FloorMaterial = Enum.Material.Sand, Level = 25, Caves = false, CaveMaterial = nil, WallSize = 15, FloorThickness = 4, UnderMaterial = Enum.Material.Air }, { Name = "Blizzard", HeightMultiplyer = 2, WallMaterial = Enum.Material.Glacier, FloorMaterial = Enum.Material.Ice, Level = 35, Caves = false, CaveMaterial = nil, WallSize = 250, FloorThickness = 4, UnderMaterial = Enum.Material.Air }, { Name = "Ogre Caves", HeightMultiplyer = 4, WallMaterial = Enum.Material.Basalt, FloorMaterial = Enum.Material.Rock, Level = 50, Caves = true, CaveMaterial = Enum.Material.Basalt, WallSize = 250, FloorThickness = 4, UnderMaterial = Enum.Material.Air }, { Name = "Ice Caves", HeightMultiplyer = 1, WallMaterial = Enum.Material.Glacier, FloorMaterial = Enum.Material.Glacier, Level = 60, Caves = true, CaveMaterial = Enum.Material.Ice, WallSize = 500, FloorThickness = 4, UnderMaterial = Enum.Material.Air }, { Name = "Mountains", HeightMultiplyer = 4, WallMaterial = Enum.Material.Rock, FloorMaterial = Enum.Material.Grass, Level = 65, Caves = false, CaveMaterial = nil, WallSize = 250, FloorThickness = 4, UnderMaterial = Enum.Material.Air }, { Name = "Ocean", HeightMultiplyer = 0.1, WallMaterial = Enum.Material.Water, FloorMaterial = Enum.Material.Water, Level = 80, Caves = false, CaveMaterial = nil, WallSize = 6.5, FloorThickness = 7, UnderMaterial = Enum.Material.Sand } } return m