I am looking for a way to get a models center of mass depending on the weight and mass of each part inside of that model. Where should I start? I have already looked at other forum posts about this topic, and I cannot find a good solution. This is where I’m at so far.
local mass, num = {},0
for i, v in pairs(workspace.Model:GetDescendants()) do
if v:IsA("BasePart") then
table.insert(mass,i,v.Position)
end
end
That’s something very hard to do, I would look on the Internet how to get the center of mass of an object, I’m not sure how you would implement it in @Roblox but it’s better than nothing…
In the Pirate Island template; workspace.Cutter.qShipManager:291
local function GetCenterOfMass(Parts)
--- Return's the world vector center of mass.
-- Lots of help from Hippalectryon :D
local TotalMass = 0
local SumOfMasses = Vector3.new(0, 0, 0)
for _, Part in pairs(Parts) do
-- Part.BrickColor = BrickColor.new("Bright yellow")
TotalMass = TotalMass + Part:GetMass()
SumOfMasses = SumOfMasses + Part:GetMass() * Part.Position
end
-- print("Sum of masses: " .. tostring(SumOfMasses))
-- print("Total mass: " .. tostring(TotalMass))
return SumOfMasses/TotalMass, TotalMass
end
I’m sorry. I made a repost since I did not do a very good job explaining my issue in this post. (I ended up just coding my own script for it and it worked somehow) I will mark your post as a solution for anybody else who comes by though.