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.

Parameters:

  • 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 (boolean): Set true to force the body to accept the shape. (Defaults to true)

Returns:

  • (Shape): The created shape.

createPart

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

Server-Only

Creates a part on the body.

Parameters:

  • 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 (boolean): Set true to force the body to accept the shape. (Defaults to true)

Returns:

  • (Shape): The created shape.

getAllSeatedCharacter

body:getAllSeatedCharacter()

Server-Only

Returns a table with all seated characters in this body.

Parameters:

  • body (Body): The body.

Returns:

  • (table): The table of all seated characters.

getAngularVelocity

body:getAngularVelocity()

Server + Client

Returns the angular velocity of the body.

Parameters:

  • body (Body): The body.

Returns:

  • (Vec3): The body's angular velocity.

getCenterOfMassPosition

body:getCenterOfMassPosition()

Server + Client

Returns the center of mass world position of the body.

Parameters:

  • body (Body): The body.

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.

Parameters:

  • body (Body): The body.

Returns:

  • (table): The table of all bodies in the creation.

getCreationId

body:getCreationId()

Server-Only

Returns the id of the creation.

Parameters:

  • body (Body): The body.

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.

Parameters:

  • body (Body): The body.

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.

Parameters:

  • body (Body): The body.

Returns:

  • (table): The table of shapes in the creation.

getId

body:getId()

Server + Client

Returns the id of the body.

Parameters:

  • body (Body): The body.

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.

Parameters:

  • body (Body): The body.

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.

Parameters:

  • body (Body): The body.

Returns:

  • (table): The table of joints in the body.

getLocalAabb

body:getLocalAabb()

Server + Client

Returns the local aabb of the body.

Parameters:

  • body (Body): The body.

Returns:

  • (Vec3): The aabb min.
  • (Vec3): The aabb max.

getMass

body:getMass()

Server + Client

Returns the mass of the body.

Parameters:

  • body (Body): The body.

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.

Parameters:

  • body (Body): The body.

Returns:

  • (table): The table of shapes in the body.

getVelocity

body:getVelocity()

Server + Client

Returns the linear velocity of the body.

Parameters:

  • body (Body): The body.

Returns:

  • (Vec3): The linear velocity of the body.

getWorld

body:getWorld()

Server + Client

Returns the world that the body exists in.

Parameters:

  • body (Body): The body.

Returns:

  • (World): The world of the body.

getWorldAabb

body:getWorldAabb()

Server + Client

Returns the world aabb of the body.

Parameters:

  • body (Body): The body.

Returns:

  • (Vec3): The aabb min.
  • (Vec3): The aabb max.

getWorldPosition

body:getWorldPosition()

Server + Client

Returns the world position of the body.

Parameters:

  • body (Body): The body.

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.

Parameters:

  • body (Body): The body.
  • tick (int): The tick.

Returns:

  • (boolean): True if the body has changed.

isBuildable

body:isBuildable()

Server + Client

Returns whether the body is buildable or not.

Parameters:

  • body (Body): The body.

Returns:

  • (boolean): Whether the body is buildable or not.

isConnectable

body:isConnectable()

Server + Client

Returns whether the body is connectable or not.

Parameters:

  • body (Body): The body.

Returns:

  • (boolean): Whether the body is connectable or not.

isConvertibleToDynamic

body:isConvertibleToDynamic()

Server + Client

Returns whether the body is convertable to dynamic or not.

Parameters:

  • body (Body): The body.

Returns:

  • (boolean): Whether the body is convertable to dynamic or not.

isDestructable

body:isDestructable()

Server + Client

Returns whether the body is destructable or not.

Parameters:

  • body (Body): The body.

Returns:

  • (boolean): Whether the body is destructable or not.

isDynamic

body:isDynamic()

Server + Client

Returns whether the body is dynamic or not.

Parameters:

  • body (Body): The body.

Returns:

  • (boolean): Whether the body is dynamic or not.

isErasable

body:isErasable()

Server + Client

Returns whether the body is erasable or not.

Parameters:

  • body (Body): The body.

Returns:

  • (boolean): Whether the body is erasable or not.

isLiftable

body:isLiftable()

Server + Client

Returns whether the body is liftable or not.

Parameters:

  • body (Body): The body.

Returns:

  • (boolean): Whether the body is liftable or not.

isOnLift

body:isOnLift()

Server + Client

Returns whether the body is on a lift or not.

Parameters:

  • body (Body): The body.

Returns:

  • (boolean): Whether the body is on a lift or not.

isPaintable

body:isPaintable()

Server + Client

Returns whether the body is paintable or not.

Parameters:

  • body (Body): The body.

Returns:

  • (boolean): Whether the body is paintable or not.

isStatic

body:isStatic()

Server + Client

Returns whether the body is static or not.

Parameters:

  • body (Body): The body.

Returns:

  • (boolean): Whether the body is static or not.

isUsable

body:isUsable()

Server + Client

Returns whether the body is interactable or not.

Parameters:

  • body (Body): The body.

Returns:

  • (boolean): Whether the body is interactable or not.

setBuildable

body:setBuildable( state )

Server-Only

Controls whether the body is buildable or not.

Parameters:

  • body (Body): The body.
  • state (boolean): Whether the body is buildable or not.

setConnectable

body:setConnectable( state )

Server-Only

Controls whether the body is connectable or not.

Parameters:

  • body (Body): The body.
  • state (boolean): Whether the body is connectable or not.

setConvertibleToDynamic

body:setConvertibleToDynamic( state )

Server-Only

Controls whether the body is convertible to dynamic or not.

Parameters:

  • body (Body): The body.
  • state (boolean): Whether the body is convertible to dynamic or not.

setDestructable

body:setDestructable( state )

Server-Only

Controls whether the body is destructable or not.

Parameters:

  • body (Body): The body.
  • state (boolean): Whether the body is destructable or not.

setErasable

body:setErasable( state )

Server-Only

Controls whether the body is erasable or not.

Parameters:

  • body (Body): The body.
  • state (boolean): Whether the body is erasable or not.

setLiftable

body:setLiftable( state )

Server-Only

Controls whether the body is liftable or not.

Parameters:

  • body (Body): The body.
  • state (boolean): Whether the body is liftable or not.

setPaintable

body:setPaintable( state )

Server-Only

Controls whether the body is paintable or not.

Parameters:

  • body (Body): The body.
  • state (boolean): Whether the body is paintable or not.

setUsable

body:setUsable( state )

Server-Only

Controls whether the body is interactable or not.

Parameters:

  • body (Body): The body.
  • state (boolean): Whether the body is interactable or not.

transformPoint

body:transformPoint( point )

Server + Client

Transforms a point from local space to world space.

Parameters:

  • body (Body): The body.
  • point (Vec3): The point in local space.

Parameters:

  • body (Vec3): The point in world space.