Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a chunk system?

Asked by 4 years ago

I am trying to make a load, unload system to make my game lag less. My world is Procedurally generated. And when I walk a direction. I want the chunks to load in as in minecraft. I have made a script that makes a chunk. A random t 10x10 chunk. Now I just need to the chunk to load in around the player and unload. If you have any kind of idea to do this. THen PLEASE TELL ME. I've been trying to implement this for 2 weeks. But I am stuck on this problem. I would be so happy if anyone could help me.

0
You could save these chunks as Region3's, store them in a table, and have a while loop that determines if the player is near the Region3. If not, remove parts inside the Region3, otherwise clone the parts into workspace. Could keep the stored parts in lighting, serverstorage, or replicatedstorage. https://developer.roblox.com/en-us/api-reference/datatype/Region3 lolzmac 207 — 4y
0
In addition to the above, you can also try the Streaming property of workspace that automatically imports / removes parts within the specified radius SerpentineKing 3885 — 4y
0
Thank god someone responded. I am going to try this:=) Hopely this work. Tysm for helping me. I've been trying to solve this for so long. And I've needed expert help for a long time now. Skydoeskey 108 — 4y
0
Also what you mean whit streaming property. I would love so much if one of you could teach me this on discord. I really am desperate to complete this since my brain is exploding from not knowing how to. And I am pretty sure its an esey problem to fix. Its just that I don't know how to. Skydoeskey 108 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

this is a very complex concept, but fortunately its not impossible..

here are a few things you should think about when brainstorming ideas of how you could approach this:

1): how to represent the objects of the map in your code.. -in order to generate something, there should be some sort of abstraction in you code that spells how to make it..

**for instance: **: you must have some abstraction of how to generate a hill, and how to differentiate between a hill and other landscapes..

example: you might indicate in your code that an asterisk(*) represents a rock, and this(idk what its called) (^) represents a tree

2): how to represent the map as text in your code:

for instance: code is just text, which means we need to get creative with how to represent non-textual fodder as text... for instance: you can represent your map as an array, or a string

now I'll attempt to make code that generates a simple map, however, this code doesn't do exactly what your looking for (generate map as player moves to places), since the code might be very long, I am going to update my answer once I am done doing so...

0
Okay nice. Thank you for trying, this is quiet hard. But I never give up. I have managed to make a 10x10x10 cube world that generates random. Like when I run the function. It creates a 10x10x10 chunk whit random wood etc. But I need to make it so that the function runs and goes in a position where the player is heading. Skydoeskey 108 — 4y
0
okay good... if you can make a 10x10x10 cube, then I am sure you can figure out how to make it generate the closer that the player gets..... since you were able to make the cube, I dont think you need an example code.. btw my approach was to model the map as a string, then pass the string to a function and the function builds the map.. User#23252 26 — 4y
Ad
Log in to vote
0
Answered by 3 years ago

I don't have any code that could possibly help but I do in fact have an idea on how to make a chunk system.

Client/Server: If you didn't know, things stored in serverStorage doesn't actually effect the Client player, except when servers are being slow.

The Idea: The idea is to do a simple/complex algorithm to see the distance of the player and it's surrounding. Depending on how you want to do a chunk system, you may need some geometry to trigonometry skills to accomplish more complex things like loading chunks in a circular fashion. Next thing up is to store any unloaded chunks to the serverStorage and load in chunks that is close to the player.

Hopefully this gives some idea to help in your situation.

Answer this question