sm.body

Associated object type: Body

A body is a collection of shapes that are built together. Bodies can be connected to other bodies using joints such as the bearing.

Functions:

  • createBody
  • getAllBodies
  • getCreationsFromBodies

  • sm.body.createBody(position, rotation=nil, isDynamic=nil)

    Server only

    Create a new body

    Parameters:

    TypeNameDescription
    Vec3positionThe body's world position.
    Quatrotation=nilThe body's world rotation. (Defaults to sm.quat.identity)
    booleanisDynamic=nilSet true if the body is dynamic or false if the body is static. (Defaults to true)

    sm.body.getAllBodies()

    Server only

    Returns a table with all the bodies in the world.

    Returns:

    TypeDescription
    tableThe table of all bodies. {Body, ...}

    sm.body.getCreationsFromBodies(bodies)

    Returns a table of tables, which is an array of tables containing bodies grouped by creation.

    A creation includes all bodies connected by joints, etc.

    Parameters:

    TypeNameDescription
    tablebodiesThe bodies to find all creation bodies from. {Body, ...}

    Returns:

    TypeDescription
    tableThe table array containing tables of all the bodies, grouped by creation. { {Body, ...}, ... }