I have a Perlin Noise code. But I also want to add caves. I found out that for the caves we need to use something called Perlin worms. I have a code for it too but it doesn’t work as I want it to here is the code:
local Seed = tick()
print("Seed is: "..Seed)
local Resolution = 4
local NumWorm = 1
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)
workspace.Terrain:FillBall(WormCF.p,Resolution,Enum.Material.Grass)
end
end
but this code doesn’t make caves. How can I make it make caves?
Please be more specific on what is not working and what is, the documentation of the source code would be highly appreciated, so we can know what a specific line of code does. The thing you described at the bottom sounds like cloning the model inside workspace but I am at the same time not sure because it’s not clear enough inside a thread for me. Thank you.
The code is working fine but it isn’t placing parts it’s placing dirt (the grass from the terrain editor) and I need it to be placing parts so that I can make those parts Cancollide false and transparancy 1 so that it makes a cave.
I am still kind of confused because I think what you need is not possible but you might try :FillBlock() function which creates a block terrain instead of ball as you have in the script. You can define in which position the terrain should be made like this for example:
local Seed = tick()
print("Seed is: "..Seed)
local Resolution = 4
local NumWorm = 1
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(WormCF.p)
Part.Parent = workspace
end
end