Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Perlin noise generation keeps putting blocks in the same position? [SOLVED]

Asked by 4 years ago
Edited 4 years ago

Im trying to make a minecrafty game and the generation technique i was using worked, but it didn't allow for proper block placing, so i made a block template that has buttons on all sides to accurate detect which side the player clicks on but the generation script keeps putting all of the blocks at the world origion

block = game.ReplicatedStorage:WaitForChild("BlockTemplate")
mapxsize = 15
mapysize = 15
mapzsize = 15
seed = math.random(0, 10000000)
noisescale = 10
amplitude = 10
blocksize =block.Size


for x = 0,mapxsize do
    for z = 0,mapzsize do
        for y = 0,mapysize do
            xnoise = math.noise(y/noisescale, z/noisescale, seed)*amplitude
            ynoise = math.noise(x/noisescale, z/noisescale, seed)*amplitude
            znoise = math.noise(x/noisescale, y/noisescale, seed)*amplitude

            density = xnoise + ynoise + znoise + y
            if density < 20 and density > 10 then 
                part = block:Clone()
                part.Name = "Block"
                part.Parent = game.Workspace.TerrainFolder
                part.Anchored = true
                part.Size = Vector3.new(blocksize, blocksize, blocksize)
                part.CFrame = CFrame.new(x*blocksize, y*blocksize, z*blocksize)
            end
        end
    end
    wait()
end
print("Generation Done")

1 answer

Log in to vote
0
Answered by
SteamG00B 1633 Moderation Voter
4 years ago

You aren't correctly making your CFrames for each block, you are giving it 3 Vector3s, when want to give it 3 numbers. So you should be setting it's CFrame like this:

 part.CFrame = CFrame.new(x*blocksize.X, y*blocksize.Y, z*blocksize.Z)
Ad

Answer this question