Hey!
So I have a script that makes a small map but for my world I need 50 times that chunk. So how would I adjust my script so chunks will load when the player moves in that direction?
This is the map script:
local Part = Instance.new("Part") --For cloning
Part.Anchored = true
Part.FormFactor = "Custom"
Part.Size = Vector3.new(1.5,5,1.5)
Part.TopSurface = "Smooth"
local spawnpoint = Instance.new("SpawnLocation")
local seed = math.random(1, 1000)
local frequency = 4
local power = 3
local resolution = 50
for x = 1, resolution do
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
local Part = Part:Clone()
Part.Parent = game.Workspace
Part.CFrame = CFrame.new(x,y,z)
spawnpoint.Position = Part.Position
Part.BrickColor = BrickColor.Green()
--[[if math.abs(y2) < .1 then
Part.BrickColor = BrickColor.Green()
elseif math.abs(y2) > .25 then
Part.BrickColor = BrickColor.Red()
else
Part.BrickColor = BrickColor.Blue()
end]]
end
end
Thanks in advanced!
I’m gonna be honest here I have 0 experience with perlin noice but I think I may be able to help you, ok so how are you storing chunk data and data from whatever your chunks are made of?
Unless you’re using Roblox terrain, I wouldn’t bother with terrain generation until Parallel Lua supports instance modifications within actors. Unless you’re only generating a smaller area and that’s it.
Games already load chunks all the time, so he should bother, in fact perlin noice is commonly used for those minecraft replicas things on roblox, I dont think he is using paralel lua either anyways, also most terrain generators use blocks as regions and fill them using terrain functions.
Those Minecraft clones all use the same source code, and it’s not very good. If you’ve ever played any of them, you’ll see how bad of an experience it is. Also perlin noise isn’t where the issue comes in. The issue comes in with only being able to place one single block at a time. If you have a chunk of 16x16 blocks, not counting filler blocks, an area of 50 chunks (25x25) is 800 blocks. You can either generate this very slowly, or lag by using tasks or other methods.
From my own experience, as somebody who’s been working on my own version, it’s not possible to create a good experience without being able to load chunks in parallel. So until then, my project is put on hold.
those minecraft clones have bad coding, I know who made the original code for those MC games and I can say their current code is much more optimized from last time still a bit laggy but this is mainly due to the awfull roblox rendering engine and not having the freedom to not render faces or areas when not needed if you are wondering they are called Engineer Studios Incorporated, the story of how the code got leaked is lengthy so I wont explain it.
The code is client-side so anyone with an exploit can decompile and save it. The lag you’re referring to isn’t the lag I’m talking about. I don’t even experience that kind of lag. The lag I’m referring to is loading chunks with as little of a delay as possible. The less delays you have, the laggier it becomes to generate. You also see that these games have a super short view distance. This is partly because of that. But it’s true that Roblox sadly doesn’t let you generate your own meshes. If it did, I could’ve resumed my project right now as the current stage of Parallel Lua would’ve actually allowed me to make use of it for this purpose. But sadly that isn’t the case.
So what do I do now? Cause the game i’m making is kinda like this but then more mincraft like. So the main thing is you can control the world but you can also play in it.
Depends on if you want to do biomes or not. Though that will complicate things quite a lot. I’d go over it, but I’m honestly way past when I should’ve been asleep. But if you’re dealing with a single biome, and even if you aren’t, you’ll want to write a function to generate any chunk at any chunk position. Then just round the player’s position to a chunk scale position and get all neighboring chunk positions and load them if they don’t already exist. The function should essentially be where you actually do any of the generation code. It will read from the perlin noise and generate accordingly without needing to have any information about neighboring chunks. This also lets you get the height of any neighboring blocks that are outside of any loaded chunks. This is important for filling gaps or doing smoother transitions between biomes. But anyway, I should probably go to sleep now. Good luck with your project
Oh and the larger your block size, especially if the chunks essentially are the chunks, you can load a much larger area much more quickly with less lag. But this does get into some decently complicated stuff, depending on how in-depth you want to go with this.
I thought of something else that might work but i’m not sure.
My idea is that i’m going to make the entire map in blender with different biomes and stuff. Cause I can make those maps in blender within a few minutes so after 4 hours of work I can have a lot of different maps.
So would this theoretically work for my game?
It really depends on what you’re going for with your game. I don’t think it would make a huge difference as you’d still have to load one thing at a time. That is unless you mean that you’re saving entire maps and loading whole maps with just one or a few meshes, then that’ll be fine. Just note that it won’t be dynamic like that.