Best method for a Chunk loader?

Currently working on a MMORPG type game with the intention of it being large with multiple locations each with a different level of style -
Was wondering what’s the best way of developing a chunk loader?

My initial thought was having a local script within the player that detects when it hits a “chunk” block, then gets the necessary values such as: Fog, ambient, Position Destination, Chunk name etc from within it before then loading it via a module script.

Just curious as to thoughts and/or suggestions.

local script:

local Player = game.Player.LocalPlayer
Player.Character:WaitForChild(“Humanoid”).Touched:Connect(function(Obj)
if Obj.Name == “ChunkLoader” then
– Gets the values from within etc.
require(game.ReplicatedStorage:WaitForChild(“ChunkLoader”)).LoadChunk(Values, etc)
else return end
end

Module script:

local Module = {}
function Module.LoadChunk(Values, etc)
– Gets the appropriate details, changing the lighting, inserting the required chunk
&& sets the Players CFrame to the appropriate location for ‘entering’ said chunk.
end
return Module

2 Likes

Transpiled

local Player = game.Player.LocalPlayer

Player.Character:WaitForChild("Humanoid").Touched:Connect(function(Obj)
	if Obj.Name == "ChunkLoader" then
		-- Gets the values from within etc.
		require(game.ReplicatedStorage:WaitForChild("ChunkLoader")).LoadChunk(Values, etc)
	else
		return
	end
end

Module script:

local Module = {}

function Module.LoadChunk(Values, etc)
	-- Gets the appropriate details, changing the lighting, inserting the required chunk
	--& sets the Players CFrame to the appropriate location for 'entering' said chunk.
end

return Module
1 Like

What is the nature of a chunk? Would it be, for example, a 25 by 25 stud boxed-off area?

1 Like

Ideally it’ll be another somewhat map; I plan for each chunk to be a somewhat providence in which the Player is able to travel between and so forth.

This sounds like a good way to do it. You’re probably going to need a loading sign though-- Seems like your maps would be so big they would take a decent amount of time to load in.

The best way to do this would probably be through an implementation of the perlin noise function, or math.noise.

There was a pretty similar post I remember helping with. The difference with this post is obvious, it was asking how to infinitely generate models:

The question you are asking is pretty much the same, just in concept of a “model” instead of a “chunk.” You could probably just store extra data in it such as fog or ambience, and update it as maybe an average of the attributes for all the current chunks loaded.

3 Likes