Hi
I tried playing around with procedural terrain generation and made an ok script. The problem now is that it’s server sided and what I need is a server sided script to generate a seed and a local script to actually render the terrain which is around the player so this way it won’t lag and the map can be huge.
This is a part of my script which generates and then renders the terrain, it’s using few parameters and Perlin noise to generate a height map and a temperature map.
-- generate terrain --
for x = 1, X do
heightMap[x] = {} -- new row
temperatureMap[x] = {} -- new row
for z = 1, Z do
heightMap[x][z] = math.noise(SEED, x/TERRAIN_SMOOTHNESS, z/TERRAIN_SMOOTHNESS) / 1.1 + 0.5
temperatureMap[x][z] = math.noise(SEED, x/TEMPERATURE_SMOOTHNESS, z/TEMPERATURE_SMOOTHNESS) / 2 + 0.5
end
end
-- render terrrain --
local count = 0
for x = 1, X do
for z = 1, Z do
createChunk(Vector3.new(x, heightMap[x][z], z), heightMap[x][z], temperatureMap[x][z])
if X >= 300 or Z >= 300 then
count += 1
if count == 75 then
wait()
count = 0
end
end
end
wait()
end
print("Terrain Generated")
I think the solution would be to generate the terrain on the server
-- generate terrain --
for x = 1, X do
heightMap[x] = {} -- new row
temperatureMap[x] = {} -- new row
for z = 1, Z do
heightMap[x][z] = math.noise(SEED, x/TERRAIN_SMOOTHNESS, z/TERRAIN_SMOOTHNESS) / 1.1 + 0.5
temperatureMap[x][z] = math.noise(SEED, x/TEMPERATURE_SMOOTHNESS, z/TEMPERATURE_SMOOTHNESS) / 2 + 0.5
end
end
And then somehow from player’s position check where the player is on the chunk grid made by the server. And then render the chunks around the player.