Howdy folks! I am attempting to divide my map into 64 chunks, this way I reload certain terrain chunks instead of the entire terrain to save on performance. The problem is I think I am creating my region3 wrong because when it is time to paste the saved chunk it doesnt paste anything. Which means it isnt copying anything.
Is my region3int16 setup incorrectly?
Heres a gif of all of the region3s visualized. They look correct to me so I am honestly really confused as to whats going wrong.
https://gyazo.com/c56d529890ca1eeab71bf7e1d51eeec2
Hopefully were able to figure this out! Thanks and have a good one!
function SetupInitialChunks()
for CurrentRow = 0, NumberOfChunks do
for CurrentColumn = 0, NumberOfChunks do
local PartMarker = Instance.new("Part")
PartMarker.Anchored = true
PartMarker.CanCollide = false
PartMarker.Size = Vector3.new(1, 500, 1)
PartMarker.Position = Vector3.new((MapSize / 2) - ((MapSize / NumberOfChunks) * CurrentRow), 0, (MapSize / 2) - ((MapSize / NumberOfChunks) * CurrentColumn))
PartMarker.Name = "ChunkMarker|" .. CurrentRow .. "|" .. CurrentColumn
PartMarker.Parent = workspace.ChunkMarkers
end
end
-- Here is where I am going wrong somewhere.
for Index, Object in ipairs(workspace.ChunkMarkers:GetChildren()) do
local OppositeMarker = workspace.ChunkMarkers:FindFirstChild("ChunkMarker|" .. string.split(Object.Name, "|")[2] + 1 .. "|" .. string.split(Object.Name, "|")[3] + 1)
if OppositeMarker ~= nil then
local RawRegion3 = Region3int16.new(Vector3int16.new(OppositeMarker.Position.X, -250, OppositeMarker.Position.Z), Vector3int16.new(Object.Position.X, 250, Object.Position.Z))
local ConvertedRegion3 = Region3.new(Vector3.new(RawRegion3.Min.X, RawRegion3.Min.Y, RawRegion3.Min.Z), Vector3.new(RawRegion3.Max.X, RawRegion3.Max.Y, RawRegion3.Max.Z))
local TerrainChunk = workspace.Terrain:CopyRegion(RawRegion3)
table.insert(TerrainChunks, {RawRegion3, ConvertedRegion3, TerrainChunk})
end
end
end