Hi there, I am working on an infinte terrain generation system using math.noise, seeds, water and much more. Right now i’m testing with a chunk loading system so that it generates as the players go.
I have never done something like this, so I am asking if anyone knows a design for doing this. Each chunk is 40 x 40 studs big, and the chunk loading radius around the player is 10 chunks (maybe). Here is my current code:
--error checks
if player.Character ~= nil then
if player.Character.PrimaryPart ~= nil then
if player.Character.PrimaryPart:GetPrimaryPartCFrame() ~= nil then
--chunk detecting system goes here
end
end
end
EDIT: I have made my own with some difficulties, so here is my new code:
if player.Character ~= nil then
if player.Character.PrimaryPart ~= nil then
if player.Character:GetPrimaryPartCFrame() == nil then
local frame = player.Character:GetPrimaryPartCFrame()
tempvar1 = math.floor(frame.Position.X / 80)
tempvar2 = math.floor(frame.Position.Z / 80)
generateChunk(seeds, Vector2.new(tempvar1 * 80, tempvar2 * 80))
end
end
end