Hello, I am trying to create an island generator with the code below.
I need help making it look more like an island, where the edges go to sand and don’t cut right off.
I have looked it up but I can’t find any examples of it in Roblox or many in lua that work in Roblox.
If anyone can help me out, and tell me how I can achieve this. I would be so grateful.
Code:
local seed = Random.new():NextNumber(1, 100000) -- seed
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local x = 200 -- x size
local z = 200 -- z size
local noisyness = 20 -- noise
local partSize = 2 -- part size
local partY = partSize * noisyness
local chance = math.random(1, 10)
local raycaster = game.ReplicatedStorage.RayCaster:Clone()
for x = -x, x do -- terain generation
for z = -z, z do
local Terrainnoise = math.noise(seed, x/150, z/150) * noisyness
local part = Instance.new("Part")
part.Name = "Part"
part.Anchored = true
part.Size = Vector3.new(partSize,partY,partSize)
part.Position = Vector3.new(x, Terrainnoise - 9, z) * partSize
part.Parent = game.Workspace.Island.Terrain
if Terrainnoise >= 0.05 then -- checks if the terrain is under a threshold
part.BrickColor = BrickColor.new("Forest green") -- grass
part.Material = Enum.Material.Grass
raycaster.Parent = workspace -- tree spawner
raycaster.Position = Vector3.new(part.Position.X,20,part.Position.Z) -- tree spawner
else
part.BrickColor = BrickColor.new("Cool yellow") -- sand
part.Material = Enum.Material.Sand
end
end
end
Could you add an image of your current island and what your desired islan looks like?
I don’t have an exact Roblox image but it shows what the islands look like
Expectations:
Reality
You can see the cuts on this one
Looks like this’s just border of generation. Increasing x and y size should help.
1 Like
I thought of that but there are a whole lot of parts and adding more will just cause lag most likely, and since it’s random there is still a chance of it happening
I’m not guarantee, but maybe try increase noisyness. It will probably will make your island smaller, and it won’t hit this border so much.
1 Like
Didn’t work very well, increasing it just made it taller revealing the edges even more, and decreasing it just made it flat, which I want some nice terrain to it.
hm… when I tried your code, I can say only 3 things:
1 - you can make islands smaller, by modifing
local Terrainnoise = math.noise(seed, x/150, z/150) * noisyness
The less 150 is, the smaller islands are
2 - you can write hard code, which will force islands to go down near borders.
3 - you can don’t change anything at all - a lot of games don’t carry about this much
1 Like
and also, 1 thing about this borders - you can load chunks of world when player comes to them.
1 Like
Yea, I wanted to do the hard code, but I’m unsure on how to detect when the generator is near a border.
I would recommend generating a two dimensional table that represents values in a circle around the center of your generation. This circle would start at value 1 in the middle and spread out to value 0 on the edges. You can then multiply each value that your perlin noise generates by its value at the coordinates in your circle table.
Here is a pretty good article: https://medium.com/@yvanscher/playing-with-perlin-noise-generating-realistic-archipelagos-b59f004d8401
1 Like
Really? You have borders X and Z. Just select 1-10 first numbers and 190-200 last numbers.
1 Like
Okay that makes sense I will try it!
Thanks, this should make things a lot easier!