mvb429800
(mvb429800)
July 8, 2024, 4:27pm
#1
I have been trying to make caves but it always has resulted in a 2d sort of cave
function density(p: Vector3, frequency): number
return math.noise(
p.X * frequency,
p.Y * frequency,
p.Z * frequency
)
end
for y = 1,16 do
for x = 1,16 do
for z = 1,16 do
local threshold = 0
local frequency = 1/4
local d = density(Vector3.new(x+(WorldSeed),y+v.ChunkStats.Offset.Value.Y,z + v.ChunkStats.Offset.Value.Z),frequency)
if d < threshold then
Blocks[y][x][z] = nil
end
end
end
end
Note the 2nd part of the code is for overwriting block placement
Try implementing perlin worms. (This is how minecraft generated caves (im not sure if they still use this method))
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)
…
Hi there,
I’m not the best at using perlin noise, mathematically wise. However, how would you make caves off a basic perlin-noise terrain?
Here’s a “test-code”, that I’ll make it better in the future, and turn it into a triangle map.
local p = workspace:WaitForChild('Part');
p.Anchored = true;
local folder = Instance.new'Folder';
folder.Parent = workspace;
folder.Name = 'Parts';
local f = 67
local coeff = 450;
function calc(x,z,o)
local height = 0;
local r = math.random(8,8*2…
mvb429800
(mvb429800)
July 8, 2024, 4:42pm
#3
Thanks but the major issue with that is that mine is a chunk based generation system and the perlin worms don’t exactly work well with that sort of generation system. I am right now trying to figure out 3D perlin noise
Sorry but I don’t think i’ll be able to provide any further help as my knowledge on this topic isn’t that great. Best of luck with your system
Fast_Duck
(Fast_Duck)
August 23, 2024, 2:17pm
#5
This is my version of perlin worms in Lua U:
local Workspace = game:GetService("Workspace")
local spawnPlace = Workspace
local seed = 1000
local blockSize = 4
local startingCFrame = CFrame.new(0, 0, 0)
local wormCurvature = 0.9
local function newBlock(targetCFrame)
local block = Instance.new("Part")
block.CFrame = targetCFrame
block.Size = Vector3.new(blockSize, blockSize, blockSize)
block.Anchored = true
block.Parent = Workspace
return block
end
for blocksSpawned = 1, 100, 1 do
local xNoise = math.noise((startingCFrame.Y + 2313.682) * wormCurvature, (startingCFrame.Z + 6721.123) * wormCurvature, seed)
local yNoise = math.noise((startingCFrame.X + 4432.572) * wormCurvature, (startingCFrame.Z - 8742.941) * wormCurvature, seed)
local zNoise = math.noise((startingCFrame.X - 5472.377) * wormCurvature, (startingCFrame.Y - 1049.189) * wormCurvature, seed)
local noise = Vector3.new(xNoise, yNoise, zNoise)
newBlock(startingCFrame)
startingCFrame += CFrame.lookAlong(startingCFrame.Position, noise).LookVector * blockSize
end