Grid Discrepancy

Problem:
I’m having trouble generating the dungeon grid in my Roblox game. I was testing the maximum size the grid could handle and increased the dimensions from 300x300 to 300x600. Everything seemed to generate correctly - nodes and rooms were placed where they should be according to my grid function. However, I noticed that the rooms and nodes weren’t lining up perfectly.

Grid Discrepancy:
The grid uses a unit size of 12, and ideally, everything (rooms, hallways, etc.) should be positioned in multiples of 12. When I checked the Z-axis positions of the nodes, I found decimals instead of whole numbers, which was unexpected since everything should have been divisible by 12. The X-axis positions seemed to be calculated correctly with no remainders.

Confusing Behavior:
This was puzzling because even though the nodes were spaced out by 12 units and stayed within the grid boundaries, and all the variables and calculations seemed correct, there was a misalignment issue. I initially thought the maximum dungeon size might be 600x600, but increasing the Z-axis size above 600 (to 612) resolved the alignment problem.

Further Testing and Observations:
I continued testing by increasing the Z-axis size in increments of 12. The alignment worked perfectly until I reached 696 units. Increasing it again to 708 fixed the issue. This same behavior occurred on the X-axis too when I changed it to 600 or 696 units. It’s important to note that I only tested up to these values, and there could be other problematic sizes. Sizes like 300 and 396 on both axes worked without any alignment issues.

In Summary:
I’m encountering a strange issue where the dungeon grid elements aren’t lining up correctly at specific dimensions that seem to be multiples of 12 plus some additional value. I’ve been unable to identify a clear pattern so far.

Video for for context
Video

My initial assumption is that it’s because of rounding errors. In your calculations, I’d make sure to have all values be whole numbers as output. That would also make sense that it only has that issue when you start getting to larger numbers, as the remaining float values that are not being noticed are building up.

Take a look at your calculations again.

Yeah, that’s what I was thinking but everything fits on the grid which is weird. example 600 was what I changed the size to, so I would have assumed that at least one of the nodes would be slightly off the grid but no they all fit in the grid bounds properly while having .5 to every Z value and why I change my just added 12 all the z values go back to whole number no remainder. 12 goes into 600 without any remainder, I even too precision rounded all output values example position so this should not be happening