Waffloid
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1606 |
|
|
| 25 Dec 2014 01:31 AM |
I seriously have no clue how.
Follow me on Twitch! I'm WaffleRBLX. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
| |
|
| |
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 25 Dec 2014 02:23 AM |
| ^The primaryPart has to be set, and isn't always the centre. |
|
|
| Report Abuse |
|
|
DavidBene
|
  |
| Joined: 26 Nov 2014 |
| Total Posts: 163 |
|
|
| 25 Dec 2014 02:29 AM |
model:GetModelCFrame() is technically the easiest way to do it.
http://wiki.roblox.com/index.php?title=API:Class/Model/GetModelCFrame
But I would not recommend it, since the wiki says it's deprecated. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 25 Dec 2014 02:46 AM |
Just made dis for u:P
http://pastebin.com/Mwd023en |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 25 Dec 2014 02:51 AM |
@Goul That doesn't work and since you put your x, y, and z tables outside the functions they will not empty them self after you run the function once so if you try and do it again it will break itself even more |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 25 Dec 2014 02:53 AM |
| I didn't make it perfect lol I just threw something together in 2 minutes.. i'm sure OP can edit it a bit if he needs to use it more than once. |
|
|
| Report Abuse |
|
|
DavidBene
|
  |
| Joined: 26 Nov 2014 |
| Total Posts: 163 |
|
|
| 25 Dec 2014 02:53 AM |
@Goulstem
Tested out your script with a part.
-------- part = Instance.new("Part",model.Parent) part.CanCollide = false part.Anchored = true part.Size = Vector3.new(1,1,1) part.Position = getModelCentre(model) --------
It doesn't work properly. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 25 Dec 2014 02:58 AM |
http://pastebin.com/k9fHy3D7
Thar
also it rounds to nearest whole number, maybe that's why it wasn't accurate with one part. |
|
|
| Report Abuse |
|
|
DavidBene
|
  |
| Joined: 26 Nov 2014 |
| Total Posts: 163 |
|
|
| 25 Dec 2014 03:04 AM |
@Goulstem
Nope, your center is still way off. I noticed that you don't take a part's size into account. Remember each part's position is located at the part's center, and not at a corner of the part. |
|
|
| Report Abuse |
|
|
DavidBene
|
  |
| Joined: 26 Nov 2014 |
| Total Posts: 163 |
|
|
| 25 Dec 2014 03:10 AM |
| The way I would probably do it is to find the lowest XYZ corner point of the model, then add (model:GetExtentsSize()/2) to it. |
|
|
| Report Abuse |
|
|
DavidBene
|
  |
| Joined: 26 Nov 2014 |
| Total Posts: 163 |
|
|
| 25 Dec 2014 03:32 AM |
I think this should work:
function compareVectors(v1,v2) if v1.X < v2.X then v2 = Vector3.new(v1.X,v2.Y,v2.Z) end if v1.Y < v2.Y then v2 = Vector3.new(v2.X,v1.Y,v2.Z) end if v1.Z < v2.Z then v2 = Vector3.new(v2.X,v2.Y,v1.Z) end return v2 end
function getCentre(model) lowestPoint = nil for index, child in pairs(model:GetChildren()) do if child:IsA("BasePart") then if lowestPoint == nil then lowestPoint = child.Position-(child.Size/2) else lowestPoint = compareVectors(child.Position-(child.Size/2),lowestPoint) end end end return lowestPoint + (model:GetExtentsSize()/2) end |
|
|
| Report Abuse |
|
|
Waffloid
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1606 |
|
|
| 25 Dec 2014 05:17 AM |
Thanks.
Follow me on Twitch! I'm WaffleRBLX. |
|
|
| Report Abuse |
|
|