Mining game optomization

I’m making a mining game my current map includes many parts and I don’t know how much load this will have on the server if I continue. would there be a way to optimize the part usage (Image below).

1 Like

Mining games like that dont usually load all of the ores and stuff at once, they generate them as players mine

So would creating the parts as the player reaches a certain Y level work?

Hi, a BIG optimization you can do fairly easily is to only create blocks that can be ‘seen’. This is scripting related however.

To figure out if a block can be seen, you simply just check if its surrounded by other blocks, if a block has blocks on every side of it, then you know it cant be seen and should not be loaded.

A 2d example of this is:
X X X
X O X
X X X

the O block is surrounded by all the other X blocks, and therefore cannot be seen and does not need to be loaded until one of those X blocks has been destroyed.

When any block is changed (e.g. mined), then you can run code to check the surrounding blocks in case they can now be seen, and then you just load that block in.

I implemented this a few months ago and it worked wonders.

Roblox occlusion culling will probably by helping out here but I am not sure how much it will help.

how would you check a blocks surrounding blocks?

So in my game, I had a 3d table which mapped all the cubes in my game.

And then its pretty easy to check surrounding cubes,

e.g.
if my cubes are like in a 200x300x400 space.

Then my 3d table will be a table with 200 values for X, 300 for Y, 400 for Z
and to look up an try I just do

myTable[57][42][23] – 57th X, 42nd Y, 23rd Z

then to check for surrounding cubes, I need to check:
X = 57, Y = 42, Z = 23

myTable[X-1][Y-1][Z-1]
myTable[X-1][Y-1][Z]
myTable[X-1][Y-1][Z+1]
etc

You do this as a for loop of course.

And basically, if there is a cube in the 3d table at every of the locations, then you know its surrounded.

There is a forum about making one of these. It isn’t very customizable and it could have more optimizations. But it’s a good starting point. Infinite Mining Generation

Here are some things I added when I used this for my game:

  • Random Dice Generator (basically allows you to make ores that are rare or common)
  • Background Culling (moves far blocks into ServerStorage so they don’t take processing power)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.