Hello! So here is my issue: I can get Perlin worms to generate just fine but I’m currently stuck trying to figure out how to create tunnels with them. I do not want to spawn in a bunch of parts and delete them one by one to create the tunnel. That causes lag and also leaves parts outside of the caves that the player won’t even see.
What I want is blocky tunnel like caves where all the blocks are 3x3x3. sizes vary from small tunnels to big caverns. I only want one layer of blocks, no blocks outside of the caves.
Here is the picture of what I have so far
And here is the code for that:
local Seed = tick()
local Resolution = 4
local NumWorm = 0
local worms = {
{},
{},
{},
{},
{},
{},
}
while wait() do
NumWorm = NumWorm+1
local sX = math.noise(NumWorm/Resolution+.1,Seed)
local sY = math.noise(NumWorm/Resolution+sX+.1,Seed)
local sZ = math.noise(NumWorm/Resolution+sY+.1,Seed)
local WormCF = CFrame.new(sX*500,sY*500,sZ*500)
print("Worm "..NumWorm.." spawning at "..WormCF.X..", "..WormCF.Y..", "..WormCF.Z)
local Dist = (math.noise(NumWorm/Resolution+WormCF.p.magnitude,Seed)+.5)*500
for i = 1,Dist do
wait()
local X,Y,Z = math.noise(WormCF.X/Resolution+.1,Seed),math.noise(WormCF.Y/Resolution+.1,Seed),math.noise(WormCF.Z/Resolution+.1,Seed)
WormCF = WormCF*CFrame.Angles(X*2,Y*2,Z*2)*CFrame.new(0,0,-Resolution)
local Part = Instance.new("Part")
Part.Anchored = true
Part.CFrame = CFrame.new(math.clamp(WormCF.p.X,-250,250),math.clamp(WormCF.p.Y,-250,250),math.clamp(WormCF.p.Z,-250,250))
Part.Parent = workspace
table.insert(worms[NumWorm],Part)
end
if NumWorm >= 6 then
break
end
end