Subdiving Workspace Into Grid Based Units (and scaling for size)

Hi Devforum,

I’m trying to create a system that will split my game’s workspace into various grid pieces based on the amount of models and BaseParts in the game. The idea being that, if I want to create (example) 4 grid zones in a map that is 300 x 300, I can identify 4 grid zones that are 150 x 150 respectively (such as getting the Vector3 positions of the boundaries of the zones).

This isn’t difficult to set-up with fixed values, but what I’m interested in is scalability. That way I can call the same function, and depending on how large my workspace contents are, I can get different grid sizes. I’ve had issues with workspace:GetBoundingBox and workspace:GetExtentsSize returning improper sizes that far exceed the size of my actual workspace contents. An added benefit is that I don’t have to manually change the numbers every time the map is expanded and new stuff is added.

Does anyone have any tips on how to go about setting this up?

Thank you!

1 Like

A really simply way of doing it is to have a huge part that represents the bounding box of your entire map. You can keep it in ServerStorage when you’re editing the map so it doesn’t get in the way, and you can move it to Workspace when you need to update it. Doing it this way prevents you from spending a lot of time figuring out a programming solution when it’s not really needed, and if you e.g. looped through all parts in Workspace to get the exact bounding box then it would potentially be slow.

1 Like