How do I get the CoM of multiple assemblies?

  1. What do you want to achieve?
    Get Center of Mass from multiple assemblies.
  2. What is the issue?
    An assembly only includes parts that are directly welded to it, however I have parts that are held on by constraints. I need the exact center of mass for my VectorForces however due to the parts held on by constraints not being part of the assembly, the assembly center of mass isn’t accurate.
  3. What solutions have you tried so far?
    I can’t think of any solutions, I am not an experienced scripter. I tried finding a similar issue on the DevHub and anywhere else and I can’t find something like my situation.
1 Like

The collective CoM of a bunch of point masses is the weighted average of the points, weighted by each point’s mass.

function assembliesCoM(assemblies)
    local com = Vector3.new()
    local mass = 0
    for _, assembly in assemblies do
        local asmMass = assemblyMass(assembly)
        local asmCom = assemblyCoM(assembly)
        com += asmCom * asmMass
        mass += asmMass
    end
    com /= mass
    return com
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.