First, I’m sorry if the title isn’t very good! I’m not really good titles right now.
I took some code I found on the devforum from a while back and modified it to fit my needs. I am currently creating a voxel world generator. I am rounding the end X, Y, and Z coordinates to a grid of 2.5 studs. (the size of the blocks) However I am pretty sure it is rounding some of the blocks to the same X and Z coordinates, therefore repeating blocks in the same position.
Although I am aware of the issue, I am quite burnt out from the beginning of school and cannot figure out what to do to fix it. I’m sure it’s an easy fix, and I apologize for that!
Here is the code:
function Round(x, mult)
return math.floor((x / mult) + 0.5) * mult
end
local Part = game:GetService("ReplicatedStorage").Block --For cloning
Part.Anchored = true
Part.FormFactor = "Custom"
Part.Size = Vector3.new(2.5,2.5,2.5)
local seed = math.random(1, 1234)
local frequency = 3
local power = 10
local resolution = 100
i = 0
for x = 1, resolution do
i = i + 1
print(i)
for z = 1, resolution do
local y1 = math.noise(
(x*frequency)/resolution,
(z*frequency)/resolution,
seed
)
local y2 = math.noise(
(x*frequency*.125)/resolution,
(z*frequency*.125)/resolution,
seed
)
local y3 = math.noise(
(x*frequency*4)/resolution,
(z*frequency*4)/resolution,
seed
)
local y = (y1*y2*power*power)+y3
--print(x, y)
local Part = Part:Clone()
Part.BrickColor = BrickColor.Random()
Part.Parent = game.Workspace
Part.CFrame = CFrame.new(Round(x,2.5),Round(y,2.5),Round(z,2.5))
end
wait()
end
If anyone can please help me fix this issue of repeating blocks, that’d be fantastic. Thanks!