Greetings,
I want to create a working chunk loading/unloading system for my game because of the use of many parts and voxels. What I want to accomplish and my questions are as follows:
What I want to accomplish:
What I question:
-
How do you make a part/voxel “unload”, and how do you make it “reload”?
-
Is it even possible to check if voxels are visible to the camera?
-
Can you make the transition from unloaded to reloaded seamless? Ex. when you look out from around a hill, the unloaded voxels/parts reappear instantaneously
Any help will be greatly appreciated.
Thanks,
R3M1X
1 Like
Hey there,
After several attempts and many devforum visits, I highly recommend turning on streamingenabled instead. A chunk loading system actually ended up making my game more laggy.
Hope this helped, HiddenKaiser
3 Likes
I will consider using it, but it is also flawed in some ways. I will continue looking into ways to better create this type of loading/reloading, but I will use it if there are no other ways to better use this type of system in my game.
Thanks for your feedback,
R3M1X
2 Likes
I understand that this will not solve your problem, but still try to use this local script inside StarterCharacterScript:
local plr = game.Players.LocalPlayer;
local char = script.Parent or plr.Character or plr.CharacterAdded:Wait();
local HRP = char:WaitForChild('HumanoidRootPart');
local Loaded = workspace:WaitForChild('Map'); -- Folder with objects to be Loaded/Unloaded
local Unloaded = game:GetService('ReplicatedStorage'):WaitForChild('Unloaded_objs'); -- The folder where the objects will be unloaded (I advise you to put it in Replicated Storage)
local Render_distance = 150; -- The distance in divisions at which objects will be loaded
game:GetService('RunService').RenderStepped:Connect(function()
for _, obj in ipairs(Loaded:GetDescendants()) do
if obj and obj:IsA('BasePart') then
if (HRP.Position - obj.Position).Magnitude > Render_distance then
obj.Parent = Unloaded;
end
end
end
for _, obj in ipairs(Unloaded:GetDescendants()) do
if obj and obj:IsA('BasePart') then
if (HRP.Position - obj.Position).Magnitude <= Render_distance then
obj.Parent = Loaded;
end
end
end
end)
Дайте знать, если это помогло!
2 Likes