#Procedural Plot System

1 messages · Page 1 of 1 (latest)

median hedge
#

My game use a 30x30x30 studs chunk.

A procedural 3x3 or 5x5 chunk plot is randomly generated, how do I find the chunk that locates in the center of the plot?

#

Just to clarify, the plot is made up of multiple "Chunk" lining up together at the same elevation

onyx steeple
# median hedge My game use a 30x30x30 studs chunk. A procedural 3x3 or 5x5 chunk plot is rando...

Well it depends on how you save the chunks. Let’s say that you give all chunks some internal cords (e.g. (0,0), (1,0) etc.)

Now I would always start from a corner, just eases the math to be frank.

Say we have a 5x5 grid starting at (7,9) (for the lower bounds of the plot, any corner would work but I would pick either the upper bounds of both x/y or both the lower bounds of both x/y to ease the math)
Then we can just quickly do -4 on both axis to quickly select the outer bounds (-4 due to the fencepost error (off by 1))

(7,9) - (4,4)= (3,5). So the plot ranges from (3,5) to (7,9)
Alternatively you can also easily get all coordinates inside the plot, by using 2 for loops; just loop through every X position (7, 6, 5, 4, 3)
Now for each one of those x positions you also loop through the Y positions
(9, 8, 7, 6, 5)
Now you’ve every coordinate pointing at a chunk inside the plot

#

Visualisations in case that helps. First shows how it would show the bounds with 2 points, second shows how the for loops would it through all 25 coordinates inside the plot

median hedge
#

Ah I got it now, thanks. That simplify things a ton.

I'll try the bound method first. (And ye, each chunk have their own cord which locates around the center of the chunk)