GetMass (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Mr Doom Bringer
No edit summary
>Sncplay42
No edit summary
Line 1: Line 1:
{{CatUp|Functions}}
{{CatUp|Functions}}
 
{|
The GetMass function returns a [[Number]] value of the object's mass. Currently, all objects in Roblox have a density of 1, which means the GetMass returns the same value as the Volume of the object (size x * size y * size x*). This can be useful to determine more than just the mass of an object, but also the size.
|<onlyinclude>
 
 
 
<onlyinclude>
{{Function|
{{Function|
name = GetMass
name = GetMass
Line 14: Line 10:
|}}
|}}
</onlyinclude>
</onlyinclude>
|}
The GetMass function returns a [[Number]] value of the object's mass. Currently, all objects in Roblox have a density of 1, which means the GetMass returns the same value as the Volume of the object. This can be useful to determine more than just the mass of an object, but also the size.
Different shapes of part (such as [[Shape (Property)|ball]] and [[RBX.lua.WedgePart (Object)|wedge]]) will have different volumes with the same [[Size (Property)|Size]] property. The GetMass function takes this into account when calculating the mass of a part.
<pre>
--get the mass of a 1x1x1 block shaped part
local part = Instance.new("Part")
part.formFactor = "Symmetric"
part.Size = Vector3.new(1,1,1)
print(part:GetMass()) --outputs "1"
--get the mass of a 1x1x1 ball-shaped part
part = Instance.new("Part")
part.Shape = "Ball"
part.Size = Vector3.new(1,1,1)
print(part:GetMass()) --outputs "0.52359879016876"
</pre>

Revision as of 13:22, 4 September 2010

GetMass( )
Returns Number object mass
Description: Returns a Number of the object's mass.

The GetMass function returns a Number value of the object's mass. Currently, all objects in Roblox have a density of 1, which means the GetMass returns the same value as the Volume of the object. This can be useful to determine more than just the mass of an object, but also the size.

Different shapes of part (such as ball and wedge) will have different volumes with the same Size property. The GetMass function takes this into account when calculating the mass of a part.

--get the mass of a 1x1x1 block shaped part
local part = Instance.new("Part")
part.formFactor = "Symmetric"
part.Size = Vector3.new(1,1,1)
print(part:GetMass()) --outputs "1"

--get the mass of a 1x1x1 ball-shaped part
part = Instance.new("Part")
part.Shape = "Ball"
part.Size = Vector3.new(1,1,1)
print(part:GetMass()) --outputs "0.52359879016876"