Oficcer_F
(Oficcer_F)
December 26, 2019, 9:29am
#1
Hi. I would like to find the center/middle of an object that contains folders, meshes, parts etc. I would just like to find the middle of that model.
But when I click the model there is no “Position” property. Is there any way of finding the center position values of that object? Thanks. Feel free to ask more questions.
5 Likes
Use hinge surfacetype and it will show you exactly where the center is.
On this picture if you look closely on the hinges it is exactly in the middle of the cylinders.
4 Likes
What I do is that I un-model the model and union the model. This why, I get the position.
astra_wr
(astra)
December 26, 2019, 2:41pm
#4
https://developer.roblox.com/en-us/api-reference/function/Model/GetBoundingBox
Model has a function Model:GetBoundingBox()
, you can use this to get the center of the model.
local model = workspace.Model
local part = workspace.center
local orientation = model:GetBoundingBox()
part.CFrame = orientation
“Orientation” returns a CFrame value, you can convert this to a Vector3 value by doing CFrame.p
(or in this case, orientation.p
)
11 Likes
Oficcer_F
(Oficcer_F)
December 27, 2019, 4:19pm
#5
Thanks. But I do not fully understand what “part” is. Since I have defined the model, but what is the “part”?
Could you give me an example?
If you were to do it with a model called “Test” in workspace.
astra_wr
(astra)
December 27, 2019, 6:03pm
#6
The “part” isn’t really necessary, I just put that in there to indicate and move the part to the model’s center.
You can just do
local model = workspace.Model
local orientation = model:GetBoundingBox()
print(orientation)
to print the CFrame
position of the center of the model, you can convert it to Vector3
by doing orientation.p
14 Likes