Before I begin I want to make clear that I know how octaves and Perlin noise work. The problem isn’t with rendering per se, more of finding out the logic in when to render a new “chunk” of terrain.
So far I can check if the player is 20 studs away from the edge with a little bit of modified AABB collision. However I stem a new problem, I don’t exactly know how I can make the “chunk” load in front of me. It seems to always clip inside the terrain. Here is my script, there are no references outside of it, everything rendered and processed is in this server script.
local resolution = 1
local size = 500
for x = 0, size, resolution do
for z = 0, size, resolution do
local height = (math.noise(x / 50, z / 50)) * 50
local cframeData = CFrame.new(x - size/2, height - 250, z - size/2)
workspace.Terrain:FillBlock(cframeData, Vector3.new(resolution, resolution, resolution), Enum.Material.Grass)
end
end
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
while true do
if char.PrimaryPart.Position.X > 230 or char.PrimaryPart.Position.Z > 230 or char.PrimaryPart.Position.X < -230 or char.PrimaryPart.Position.Z < -230 then
for x = 0, size, resolution do
for z = 0, size, resolution do
local height = (math.noise(x / 50, z / 50)) * 50
local cframeData = CFrame.new(char.PrimaryPart.Position.X - x, height - 250, char.PrimaryPart.Position.Z - z)
workspace.Terrain:FillBlock(cframeData, Vector3.new(resolution, resolution, resolution), Enum.Material.Grass)
end
end
end
wait()
end
end)
I am not asking you to rewrite my script, you are willing to by the way I just want an explanation on the logic I need to do to achieve something similar to this Roblox Procedural Terrain Part 2 - Plains - YouTube