Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Find the center of a model?

Asked by 6 years ago
Edited 6 years ago

I don't want to manually set a part in the middle as the primary part, so any ideas how to do the math or whatever I need to do?

Or how to find the nearest model to a Vector3, that's what I'm trying to do with this in the end

Thanks in advance!

0
Perhaps if you get a vector3 for the center of the model you could store that in a Vector3Value object and calculate the distance/magnitude between the two models by subtracting their Vector3 positions ultrasonicboomer 85 — 6y

1 answer

Log in to vote
1
Answered by
Jo_Bot 67
6 years ago

Hmm, I guess you could add the positions of all the parts in the model and find the average. For instance, if you have 24 parts in a model, you would add all of the parts' positions and then divide them by 24. That should give a center, but maybe I am wrong, I do not know. Sorry I didn't give a script, it should be simple, probably lots of variables though if you have a lot of parts...

0
You could use a for loop instead of having to reference every single part ultrasonicboomer 85 — 6y
0
Yes, that would work better than referencing each part. Jo_Bot 67 — 6y
0
Yea I was just watching youtube and I thought "why am I so stupid I could average the positions" then I came here to delete the question User#1007 6 — 6y
0
Wait no that wouldn't do what I want, if there's more parts to 1 side it's gonna be closer there... User#1007 6 — 6y
0
At this point, I recommend just having an invisible center part as the PrimaryPart... Jo_Bot 67 — 6y
Ad

Answer this question