Skip to main content

PhysicsUtils

General physics library for use on Roblox

Functions

getConnectedParts

PhysicsUtils.getConnectedParts(partBasePart) → {BasePart}

Retrieves all connected parts of a part, plus the connected part.

getMass

PhysicsUtils.getMass(parts{BasePart}) → number

Retrieves mass of all parts

estimateBuoyancyContribution

PhysicsUtils.estimateBuoyancyContribution(parts{BasePart}) → (
number,--

buoyancy

number,--

mass

number--

volume

)

Estimate buoyancy contributed by parts

getCenterOfMass

PhysicsUtils.getCenterOfMass(parts{BasePart}) → (
Vector3,--

position

number--

mass

)

Return's the world vector center of mass.

momentOfInertia

PhysicsUtils.momentOfInertia(
partBasePart,
axisVector3,
originVector3
) → number

Calculates the moment of inertia of a solid cuboid.

warning

This is wrong for Roblox. Roblox has hollow cuvoids as parts

bodyMomentOfInertia

PhysicsUtils.bodyMomentOfInertia(
partsThepartstouse,
axistheaxistouse(
Shouldbetorque,
oroffsetcrossforce
),
originTheoriginoftheaxis(shouldbecenterofmassoftheparts)
) → number

Given a connected body of parts, returns the moment of inertia of these parts

applyForce

PhysicsUtils.applyForce(
partBasePart,
forceVector3,--

the force vector to apply

forcePositionVector3--

The position that the force is to be applied from (World vector).

) → ()

Applies a force to a Roblox body.

tip

Roblox has :ApplyImpulse now as an API surface, so I recommend using that instead.

It should be noted that setting the velocity to one part of a connected part on Roblox sets the velocity of the whole physics model. http://xboxforums.create.msdn.com/forums/p/34179/196459.aspx http://www.cs.cmu.edu/~baraff/sigcourse/notesd1.pdf

acceleratePart

PhysicsUtils.acceleratePart(
partBasePart,
emittingPartBasePart,
accelerationVector3
) → ()

Accelerates a part utilizing newton's laws. emittingPart is the part it's emitted from. force = mass * acceleration

Show raw api
{
    "functions": [
        {
            "name": "getConnectedParts",
            "desc": "Retrieves all connected parts of a part, plus the connected part.",
            "params": [
                {
                    "name": "part",
                    "desc": "",
                    "lua_type": "BasePart"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ BasePart }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 16,
                "path": "src/physicsutils/src/Shared/PhysicsUtils.lua"
            }
        },
        {
            "name": "getMass",
            "desc": "Retrieves mass of all parts",
            "params": [
                {
                    "name": "parts",
                    "desc": "",
                    "lua_type": "{ BasePart }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 27,
                "path": "src/physicsutils/src/Shared/PhysicsUtils.lua"
            }
        },
        {
            "name": "estimateBuoyancyContribution",
            "desc": "Estimate buoyancy contributed by parts",
            "params": [
                {
                    "name": "parts",
                    "desc": "",
                    "lua_type": "{ BasePart }"
                }
            ],
            "returns": [
                {
                    "desc": "buoyancy",
                    "lua_type": "number"
                },
                {
                    "desc": "mass",
                    "lua_type": "number"
                },
                {
                    "desc": "volume",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 42,
                "path": "src/physicsutils/src/Shared/PhysicsUtils.lua"
            }
        },
        {
            "name": "getCenterOfMass",
            "desc": "Return's the world vector center of mass.",
            "params": [
                {
                    "name": "parts",
                    "desc": "",
                    "lua_type": "{ BasePart }"
                }
            ],
            "returns": [
                {
                    "desc": "position",
                    "lua_type": "Vector3"
                },
                {
                    "desc": "mass",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 68,
                "path": "src/physicsutils/src/Shared/PhysicsUtils.lua"
            }
        },
        {
            "name": "momentOfInertia",
            "desc": "Calculates the moment of inertia of a solid cuboid.\n\n:::warning\nThis is wrong for Roblox. Roblox has hollow cuvoids as parts\n:::",
            "params": [
                {
                    "name": "part",
                    "desc": "",
                    "lua_type": "BasePart"
                },
                {
                    "name": "axis",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "origin",
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 92,
                "path": "src/physicsutils/src/Shared/PhysicsUtils.lua"
            }
        },
        {
            "name": "bodyMomentOfInertia",
            "desc": "Given a connected body of parts, returns the moment of inertia of these parts",
            "params": [
                {
                    "name": "parts",
                    "desc": "",
                    "lua_type": "The parts to use"
                },
                {
                    "name": "axis",
                    "desc": "",
                    "lua_type": "the axis to use (Should be torque, or offset cross force)"
                },
                {
                    "name": "origin",
                    "desc": "",
                    "lua_type": "The origin of the axis (should be center of mass of the parts)"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 114,
                "path": "src/physicsutils/src/Shared/PhysicsUtils.lua"
            }
        },
        {
            "name": "applyForce",
            "desc": "Applies a force to a Roblox body.\n\n:::tip\nRoblox has :ApplyImpulse now as an API surface, so I recommend using that\ninstead.\n:::\n\nIt should be noted that setting the velocity to one part of a connected part on Roblox sets\nthe velocity of the whole physics model.\nhttp://xboxforums.create.msdn.com/forums/p/34179/196459.aspx\nhttp://www.cs.cmu.edu/~baraff/sigcourse/notesd1.pdf",
            "params": [
                {
                    "name": "part",
                    "desc": "",
                    "lua_type": "BasePart"
                },
                {
                    "name": "force",
                    "desc": "the force vector to apply",
                    "lua_type": "Vector3"
                },
                {
                    "name": "forcePosition",
                    "desc": "The position that the force is to be applied from (World vector).",
                    "lua_type": "Vector3"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 141,
                "path": "src/physicsutils/src/Shared/PhysicsUtils.lua"
            }
        },
        {
            "name": "acceleratePart",
            "desc": "Accelerates a part utilizing newton's laws. emittingPart is the part it's emitted from.\nforce = mass * acceleration",
            "params": [
                {
                    "name": "part",
                    "desc": "",
                    "lua_type": "BasePart"
                },
                {
                    "name": "emittingPart",
                    "desc": "",
                    "lua_type": "BasePart"
                },
                {
                    "name": "acceleration",
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 172,
                "path": "src/physicsutils/src/Shared/PhysicsUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "PhysicsUtils",
    "desc": "General physics library for use on Roblox",
    "source": {
        "line": 5,
        "path": "src/physicsutils/src/Shared/PhysicsUtils.lua"
    }
}