Skip to main content

Body

Associated namespace: sm.body

A userdata object representing a body in the game.

Values:
  • angularVelocity [ Vec3 ]

    • Get: The angular velocity of the body.
  • buildable [ bool ]

    • Get: Whether the body is buildable or not.
    • Set: (Server-Only) Controls whether a body is buildable.
  • centerOfMassPosition [ Vec3 ]

    • Get: The center of mass world position of a body.
  • connectable [ bool ]

    • Get: Whether the body is connectable or not.
    • Set: (Server-Only) Controls whether a body is connectable.
  • convertableToDynamic [ bool ]

    • Get: Whether the body is convertible to dynamic or not.
    • Set: (Server-Only) Controls whether a body is convertible to dynamic.
  • destructable [ bool ]

    • Get: Whether the body is destructable or not.
    • Set: (Server-Only) Controls whether a body is destructable.
  • erasable [ bool ]

    • Get: Whether the body is erasable or not.
    • Set: (Server-Only) Controls whether a body is erasable.
  • id [ int ]

    • Get: The id of the body.
  • liftable [ bool ]

    • Get: Whether the body is liftable or not.
    • Set: (Server-Only) Controls whether a body is liftable.
  • mass [ number ]

    • Get: The mass of the body.
  • paintable [ bool ]

    • Get: Whether the body is paintable or not.
    • Set: (Server-Only) Controls whether a body is paintable.
  • usable [ bool ]

    • Get: Whether the body is interactable or not.
    • Set: (Server-Only) Controls whether a body is interactable.
  • velocity [ Vec3 ]

    • Get: The linear velocity of the body.
  • worldPosition [ Vec3 ]

    • Get: The world position of the body.
  • worldRotation [ Quat ]

    • Get: The world rotation of the body.
Operations:
OperationDescription
Body == BodyChecks if two instances of Body refer to the same Body.

Functions

createBlock

body:createBlock( uuid, size, position, forceAccept )
Server-Only

Creates a block on the body.

Arguments:
  • body [ Body ]: The body.
  • uuid [ Uuid ]: The uuid of the shape.
  • size [ Vec3 ]: The shape's size.
  • position [ Vec3 ]: The shape's local position.
  • forceAccept [ bool ]: Set true to force the body to accept the shape. (Defaults to true)
Returns:

createPart

body:createPart( uuid, position, z-axis, x-axis, forceAccept )
Server-Only

Creates a part on the body.

Arguments:
  • body [ Body ]: The body.
  • uuid [ Uuid ]: The uuid of the shape.
  • position [ Vec3 ]: The shape's local position.
  • z-axis [ Vec3 ]: The shape's local z direction.
  • x-axis [ Vec3 ]: The shape's local x direction.
  • forceAccept [ bool ]: Set true to force the body to accept the shape. (Defaults to true)
Returns:

getAllSeatedCharacter

body:getAllSeatedCharacter()
Server-Only

Returns a table with all seated characters in this body.

Arguments:
Returns:
  • [ table ]: The table of all seated characters.

getAngularVelocity

body:getAngularVelocity()
Server + Client

Returns the angular velocity of the body.

Arguments:
Returns:
  • [ Vec3 ]: The body's angular velocity.

getCenterOfMassPosition

body:getCenterOfMassPosition()
Server + Client

Returns the center of mass world position of the body.

Arguments:
Returns:
  • [ Vec3 ]: The body's center of mass position.

getCreationBodies

body:getCreationBodies()
Server + Client

Returns a table of all bodies in the creation.

A creation includes all bodies connected by joints, etc.

Arguments:
Returns:
  • [ table ]: The table of all bodies in the creation.

getCreationId

body:getCreationId()
Server-Only

Returns the id of the creation.

Arguments:
Returns:
  • [ int ]: The id of the creation.

getCreationJoints

body:getCreationJoints()
Server + Client

Returns a table of all joints that are part of the creation.

A creation includes all bodies connected by joints, etc.

Arguments:
Returns:
  • [ table ]: The table of joints in the creation.

getCreationShapes

body:getCreationShapes()
Server + Client

Returns a table of all shapes that are part of the creation.

A creation includes all bodies connected by joints, etc.

Arguments:
Returns:
  • [ table ]: The table of shapes in the creation.

getId

body:getId()
Server + Client

Returns the id of the body.

Arguments:
Returns:
  • [ int ]: The id of the body.

getInteractables

body:getInteractables()
Server + Client

Returns a table of all interactables that are part of a body.

This will not return interactables in neighbouring bodies connected by joints, etc.

Arguments:
Returns:
  • [ table ]: The table of interactables in the body.

getJoints

body:getJoints()
Server + Client

Returns a table of all joints that are part of a body.

This will not return joints in neighbouring bodies.

Arguments:
Returns:
  • [ table ]: The table of joints in the body.

getLocalAabb

body:getLocalAabb()
Server + Client

Returns the local aabb of the body.

Arguments:
Returns:

getMass

body:getMass()
Server + Client

Returns the mass of the body.

Arguments:
Returns:
  • [ number ]: The mass of the body.

getShapes

body:getShapes()
Server + Client

Returns a table of all shapes that are part of the body.

This will not return shapes in neighbouring bodies connected by joints, etc.

Arguments:
Returns:
  • [ table ]: The table of shapes in the body.

getVelocity

body:getVelocity()
Server + Client

Returns the linear velocity of the body.

Arguments:
Returns:
  • [ Vec3 ]: The linear velocity of the body.

getWorld

body:getWorld()
Server + Client

Returns the world that the body exists in.

Arguments:
Returns:
  • [ World ]: The world of the body.

getWorldAabb

body:getWorldAabb()
Server + Client

Returns the world aabb of the body.

Arguments:
Returns:

getWorldPosition

body:getWorldPosition()
Server + Client

Returns the world position of the body.

Arguments:
Returns:
  • [ Vec3 ]: The body's world position.

hasChanged

body:hasChanged( tick )
Server + Client

Returns true if the given tick is lower than the tick the body was last changed.

Arguments:
  • body [ Body ]: The body.
  • tick [ int ]: The tick.
Returns:
  • [ bool ]: True if the body has changed.

isBuildable

body:isBuildable()
Server + Client

Returns whether the body is buildable or not.

Arguments:
Returns:
  • [ bool ]: Whether the body is buildable or not.

isConnectable

body:isConnectable()
Server + Client

Returns whether the body is connectable or not.

Arguments:
Returns:
  • [ bool ]: Whether the body is connectable or not.

isConvertibleToDynamic

body:isConvertibleToDynamic()
Server + Client

Returns whether the body is convertable to dynamic or not.

Arguments:
Returns:
  • [ bool ]: Whether the body is convertable to dynamic or not.

isDestructable

body:isDestructable()
Server + Client

Returns whether the body is destructable or not.

Arguments:
Returns:
  • [ bool ]: Whether the body is destructable or not.

isDynamic

body:isDynamic()
Server + Client

Returns whether the body is dynamic or not.

Arguments:
Returns:
  • [ bool ]: Whether the body is dynamic or not.

isErasable

body:isErasable()
Server + Client

Returns whether the body is erasable or not.

Arguments:
Returns:
  • [ bool ]: Whether the body is erasable or not.

isLiftable

body:isLiftable()
Server + Client

Returns whether the body is liftable or not.

Arguments:
Returns:
  • [ bool ]: Whether the body is liftable or not.

isOnLift

body:isOnLift()
Server + Client

Returns whether the body is on a lift or not.

Arguments:
Returns:
  • [ bool ]: Whether the body is on a lift or not.

isPaintable

body:isPaintable()
Server + Client

Returns whether the body is paintable or not.

Arguments:
Returns:
  • [ bool ]: Whether the body is paintable or not.

isStatic

body:isStatic()
Server + Client

Returns whether the body is static or not.

Arguments:
Returns:
  • [ bool ]: Whether the body is static or not.

isUsable

body:isUsable()
Server + Client

Returns whether the body is interactable or not.

Arguments:
Returns:
  • [ bool ]: Whether the body is interactable or not.

setBuildable

body:setBuildable( state )
Server-Only

Controls whether the body is buildable or not.

Arguments:
  • body [ Body ]: The body.
  • state [ bool ]: Whether the body is buildable or not.

setConnectable

body:setConnectable( state )
Server-Only

Controls whether the body is connectable or not.

Arguments:
  • body [ Body ]: The body.
  • state [ bool ]: Whether the body is connectable or not.

setConvertibleToDynamic

body:setConvertibleToDynamic( state )
Server-Only

Controls whether the body is convertible to dynamic or not.

Arguments:
  • body [ Body ]: The body.
  • state [ bool ]: Whether the body is convertible to dynamic or not.

setDestructable

body:setDestructable( state )
Server-Only

Controls whether the body is destructable or not.

Arguments:
  • body [ Body ]: The body.
  • state [ bool ]: Whether the body is destructable or not.

setErasable

body:setErasable( state )
Server-Only

Controls whether the body is erasable or not.

Arguments:
  • body [ Body ]: The body.
  • state [ bool ]: Whether the body is erasable or not.

setLiftable

body:setLiftable( state )
Server-Only

Controls whether the body is liftable or not.

Arguments:
  • body [ Body ]: The body.
  • state [ bool ]: Whether the body is liftable or not.

setPaintable

body:setPaintable( state )
Server-Only

Controls whether the body is paintable or not.

Arguments:
  • body [ Body ]: The body.
  • state [ bool ]: Whether the body is paintable or not.

setUsable

body:setUsable( state )
Server-Only

Controls whether the body is interactable or not.

Arguments:
  • body [ Body ]: The body.
  • state [ bool ]: Whether the body is interactable or not.

transformPoint

body:transformPoint( point )
Server + Client

Transforms a point from local space to world space.

Arguments:
  • body [ Body ]: The body.
  • point [ Vec3 ]: The point in local space.
Arguments:
  • body [ Vec3 ]: The point in world space.