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

How i can convert mass to density?

Asked by
AIexR32 11
2 years ago

So i want to make SetMass function but i dont know how to convert mass to density so i can get mass from part and put that mass to another part
i have made this function but its very unprecise

local Character = script.Parent
local HumanoidRootPart = Character.PrimaryPart

local function RoundFloat(Float,Precise) Precise = Precise or 1
    return tonumber(string.format("%."..Precise.."f",Float))
end

local function SetMass(Part,Mass) Mass = RoundFloat(Mass)
    local CurrentMass = RoundFloat(Part.AssemblyMass)
    local PartPhysicalProperties = PhysicalProperties.new(Part.Material)
    local Density = PartPhysicalProperties.Density
    local Volume = RoundFloat(CurrentMass / Density)
    local Volume2 = RoundFloat(Mass / Density)
    Density = RoundFloat(Mass/CurrentMass - Density,2)
    print(Density)


    Part.CustomPhysicalProperties = PhysicalProperties.new(Density,
        PartPhysicalProperties.Friction,PartPhysicalProperties.Elasticity)
    print(Part.AssemblyMass)
end

SetMass(workspace.Part,HumanoidRootPart.AssemblyMass)

0
Density = Mass / Volume beachpartytime 0 — 2y
0
Thanks! Can you post it as answer so i can check this post as answered? AIexR32 11 — 2y

Answer this question