Edit: Looks like I got what I wanted! Roblox added Assemblies, which now correctly handle this via the “AssemblyMass” property. Hooray!
Hi!
As a roblox developer, it is currently… inconvenient… to calculate the total mass of a system/model of connected (via constraints or welds) parts.
In the current roblox-lua API, either by design or due to a bug, getting the mass of a part (through .Mass or :GetMass() ) returns only the mass of the part, and ignores all connected parts.
This is great, but if you’re using body movers and trying to give a mover a specific acceleration (by setting it’s max force such that F=MA), it’s not useful on it’s own, since the force considers the mass of the whole system of connected parts (as it should).
Currently, in order to accurately specify a force for a model, You need to manually calculate the total mass of the model by doing something like:
local total_mass = 0
for index, part in pairs(Model:GetDescendants() ) do
if part:IsA("BasePart") then
total_mass += part.Mass
end
end
which isn’t hard, just kind of inconvenient.
It would be nice if “Model” class instances had a native “:GetMass()” method that did this function or something similar, and/or if "BasePart"s had a “:GetEffectiveMass()” method (perhaps with a better name).
Use Cases:
- Giving a vehicle/space ship/obstacle a “max acceleration” value (by setting the body mover’s force equal to the mass of the vehicle * your desired acceleration)
- Doing the opposite, and getting the acceleration from the force active on a mass and the mass
I can’t think of many other use cases, but these seem “broad” enough to me (especially the former).
This is a pretty minor grievance, but in a physics-based platform like roblox, it just kind of makes sense to have this method - at least to me.
Since this seems like a pretty generic problem, I apologize if this has been suggested (and or declined) before; the last reference to this sort of thing that I could find dated back to 2015. I figured it was worth reviving.
I also apologize if there already exists an API method/property that does this; I must have missed it.
SIDE NOTE 1: This could also be “solved” by giving BodyMovers a “max acceleration” property, but that seems to be a lot more niche (albeit much easier to use for a newbie dev).
SIDE NOTE 2: I noticed that the BasePart class has both a .Mass property and a “:GetMass()” method that simply reads the (already readable) .Mass property. I personally thought GetMass would get the mass of the model/all connected parts. Could it be bugged?
TL:DR:
Please let us easily find the mass of a whole model of connected parts, so that we can easily accurately set the maximum acceleration of body movers.
Thanks for reading!
Hellhawk