Hello,
I would like to make a grid building system, but you can rotate objects. That causes for some problems of the bounds of the building region.
- Br, iSyriux
Model:GetBoundingBox() will return the CFrame and size of a model, and if there is no primary part, will be relative to world space.
For a building system though, I’d assume you are using primary parts, which means it will be object space relative. It’s the only API I could find on something like this.
You can get the coordinates of each corner to determine the extents of the bounding box in global space. Then the position of the center of the bounding box should be the same position as the part.
GetBoundingBox is definitely the easiest way to do this. If you aren’t using primary parts, do what @1Joeb said
If you’re using primary parts, you could set the part’s orientation, get the bounding box, then set the part’s orientation back.
If you have a block shaped part like the black rectangle in the picture you can:
- Use the cframe’s look, up, and right vectors and the size vector to find the corners of the box
- Find the greatest and least x, y, and z values
- Use those values to create a box (only works relative to world space without some math)