Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```lua
- local updatesPerSecond = 5
- local chunkSize = 16
- local blockSize = 2.5
- local totalChunkSize = chunkSize * blockSize
- local currentChunk = Vector2.new(0, 0)
- local currentChunkModel = Instance.new("Folder", game.Workspace)
- local isFirstTime = true
- function getCurrentChunk()
- if game.Players.LocalPlayer.Character.HumanoidRootPart ~= nil then
- local plrPos = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
- local cX = math.ceil(plrPos.X / (totalChunkSize))
- local cZ = math.ceil(plrPos.Z / (totalChunkSize))
- return Vector2.new(cX, cZ)
- else
- return currentChunk
- end
- end
- while wait (1 / updatesPerSecond) do
- -- Update chunks and render new ones if needed.
- print(currentChunk.X .. ", ".. currentChunk.Y)
- if currentChunk ~= getCurrentChunk() or isFirstTime then
- isFirstTime = false
- currentChunk = getCurrentChunk()
- print("Spawning new chunk at (".. currentChunk.X ..", ".. currentChunk.Y ..")...")
- currentChunkModel:ClearAllChildren()
- for x = -(chunkSize), (chunkSize), blockSize do
- for z = -(chunkSize), (chunkSize), blockSize do
- local noise = 1--(math.noise(x + (currentChunk.X * chunkSize) / 20, z + (currentChunk.Y * chunkSize) / 20) + 2) * 50
- print(noise)
- for y = 0, noise, 1 do
- local block = Instance.new("Part", currentChunkModel)
- block.Anchored = true
- block.Size = Vector3.new(blockSize, blockSize, blockSize)
- block.CFrame = CFrame.new(x + (getCurrentChunk().X * 16), y, z + (getCurrentChunk().Y * 16))
- block.TopSurface = Enum.SurfaceType.SmoothNoOutlines
- block.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
- block.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
- block.RightSurface = Enum.SurfaceType.SmoothNoOutlines
- block.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
- block.BackSurface = Enum.SurfaceType.SmoothNoOutlines
- block.BrickColor = BrickColor.Green()
- end
- end
- end
- end
- end
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement