GetMass (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Sncplay42
No edit summary
>ArceusInator
redirect
Line 1: Line 1:
{{CatUp|Functions}}
#REDIRECT [[GetMass (Method)]]
{|
|<onlyinclude>
{{Function|
name = GetMass
|arguments =
|returns = [[Number]] ''object mass''
|description = Returns a Number of the object's mass.
|object = [[RBX.lua.FlagStand (Object)|Flagstand]], [[RBX.lua.Part (Object)|Part]], [[RBX.lua.Seat (Object)|Seat]], [[RBX.lua.SpawnLocation (Object)|SpawnLocation]]
|}}
</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 16:35, 11 January 2011

Redirect to: