I’m working on creating a module to give the realistic density but it’s definitely gone wrong somewhere.
This is the part where I calculate it.
local partSize = part.Size
local studsInAMeter = 3.57 --1 stud = 0.28 meters
local volume = (partSize.X/studsInAMeter) * (partSize.Y/studsInAMeter) * (partSize.Z/studsInAMeter)
local materialMass = self.MaterialMassesPerCubicMeterInKG[tostring(part.Material)]
local mass = (materialMass * (partSize.X/studsInAMeter)) + (materialMass * (partSize.Y/studsInAMeter)) + (materialMass * (partSize.Z/studsInAMeter))
I get the volume by dividing the X,Y and Z by how many studs are in a meter and then multiplying all those together. I then get it’s material weight per cubic meter.
Once I have the weight I multiply it by each X,Y and Z and then add them all together.
self.MaterialMassesPerCubicMeterInKG is shown here:
Is there a difference between what you’re trying to do with certain calculations and what the engine already provides as far as getting the density of a material goes?
local materialDensity = PhysicalProperties.new(Enum.Material.Grass).Density
I figure that getting density with long equations may not provide you with intended results such as being realistic for real world physics but not so much for Roblox.
Fixed, there’s not supposed to be a parenthesis there at all. I also used the wrong datatype, there’s no Custom in the constructor.
As for creating physical properties, yes you can. The point of the PhysicalProperties constructor is to allow you to, as the class name states, create custom physical properties to apply to a BasePart.