Offset between Model's PrimaryPart and its ExtentSize?

As a developer, I want to move several models next to each other such that their bounding boxes are touching.

The models are arbitrary from a large preset list and all have different proportions but have PrimaryPart set, so :GetExtentsSize() works, but I want to know the relationship between the center of the bounding box returned by GetExtentsSize and the position of the PrimaryPart.

For an illustration, I am looking for the red vector in this diagram:
image

EDIT: moved from Scripting Support to Engine Features

I know it’s deprecated, but why not use model:GetModelCFrame() and calculate the difference from the primary part position to the corner of the model with the model CFrame and extents size?

Roblox is working on adding a new function called GetBoundingBox, which returns the CFrame and Size of the bounding box of a model. Once this comes out, simply use

ModelCF, ModelSize = Model:GetBoundingBox()
Offset = Model.PrimaryPart.Position-ModelCF.p

The new function is listed here, shown as still pending.
https://www.robloxdev.com/resources/release-note/Release-Note-for-357

Alternatively you can use the deprecated method usering suggested, since it still appears to work.

5 Likes

Oh wow I didn’t even know about that. Roblox is adding everything that I have been working around for the past week or so all of the sudden :open_mouth:

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