Functions for interacting with Box2D bodies.
Version: alpha
| FUNCTIONS | |
|---|---|
| b2d.body.apply_angular_impulse() | Apply an angular impulse. |
| b2d.body.apply_angular_impulse() | Apply an angular impulse. |
| b2d.body.apply_force() | Apply a force at a world point. If the force is no... |
| b2d.body.apply_force() | Apply a force at a world point. If the force is no... |
| b2d.body.apply_force_to_center() | Apply a force to the center of mass. This wakes up the body. |
| b2d.body.apply_force_to_center() | Apply a force to the center of mass. This wakes up the body. |
| b2d.body.apply_linear_impulse() | Apply an impulse at a point. This immediately modi... |
| b2d.body.apply_linear_impulse() | Apply an impulse at a point. This immediately modi... |
| b2d.body.apply_linear_impulse_to_center() | Apply a linear impulse to the center of mass. |
| b2d.body.apply_torque() | Apply a torque. This affects the angular velocity ... |
| b2d.body.apply_torque() | Apply a torque. This affects the angular velocity ... |
| b2d.body.compute_aabb() | Compute the world AABB of all body shapes. |
| b2d.body.create_chain() | Create a chain and attach its segment shapes to this body. |
| b2d.body.create_fixture() | Creates a fixture and attach it to this body. Use ... |
| b2d.body.create_fixture() | Creates a fixture from a shape and attach it to th... |
| b2d.body.create_shape() | Creates a shape and attaches it to this body |
| b2d.body.destroy_fixture() | Destroy a fixture from a body. |
| b2d.body.destroy_shape() | Destroy a shape. This removes the shape from the b... |
| b2d.body.dump() | Print the body representation to the log output |
| b2d.body.enable_contact_events() | Enable or disable contact events on all body shapes. |
| b2d.body.enable_hit_events() | Enable or disable hit events on all body shapes. |
| b2d.body.enable_sleep() | You can disable sleeping on this body. If you disable sleeping, the body will be woken. |
| b2d.body.get_angle() | Get the angle in radians. |
| b2d.body.get_angular_damping() | Get the angular damping of the body. |
| b2d.body.get_angular_damping() | Get the angular damping of the body. |
| b2d.body.get_angular_velocity() | Get the angular velocity. |
| b2d.body.get_angular_velocity() | Get the angular velocity. |
| b2d.body.get_contact_data() | Get touching contact data for a body. |
| b2d.body.get_contact_list() | Get the list of all contacts attached to this body. |
| b2d.body.get_contact_list() | Get the list of all contacts attached to this body. |
| b2d.body.get_fixtures() | Get the fixtures attached to this body. |
| b2d.body.get_force() | Get the total force currently applied on this object |
| b2d.body.get_force() | Get the total force currently applied on this object |
| b2d.body.get_gravity_scale() | Get the gravity scale of the body. |
| b2d.body.get_gravity_scale() | Get the gravity scale of the body. |
| b2d.body.get_inertia() | Get the rotational inertia of the body about the local origin. |
| b2d.body.get_joints() | Get the joints attached to this body. |
| b2d.body.get_joints() | Get the joints attached to this body. |
| b2d.body.get_linear_damping() | Get the linear damping of the body. |
| b2d.body.get_linear_damping() | Get the linear damping of the body. |
| b2d.body.get_linear_velocity() | Get the linear velocity of the center of mass. |
| b2d.body.get_linear_velocity() | Get the linear velocity of the center of mass. |
| b2d.body.get_linear_velocity_from_local_point() | Get the world velocity of a local point. |
| b2d.body.get_linear_velocity_from_local_point() | Get the world velocity of a local point. |
| b2d.body.get_linear_velocity_from_world_point() | Get the world linear velocity of a world point attached to this body. |
| b2d.body.get_linear_velocity_from_world_point() | Get the world linear velocity of a world point attached to this body. |
| b2d.body.get_local_center() | Get the local position of the center of mass. |
| b2d.body.get_local_center_of_mass() | Get the local position of the center of mass. |
| b2d.body.get_local_point() | Gets a local point relative to the body's origin given a world point. |
| b2d.body.get_local_point() | Gets a local point relative to the body's origin given a world point. |
| b2d.body.get_local_vector() | Gets a local vector given a world vector. |
| b2d.body.get_local_vector() | Gets a local vector given a world vector. |
| b2d.body.get_mass() | Get the total mass of the body. |
| b2d.body.get_mass() | Get the total mass of the body. |
| b2d.body.get_mass_data() | Get the mass data of the body. |
| b2d.body.get_mass_data() | Get the mass data of the body. |
| b2d.body.get_name() | Get the body name. |
| b2d.body.get_next() | Get the next body in the world's body list. |
| b2d.body.get_position() | Get the world body origin position. |
| b2d.body.get_position() | Get the world body origin position. |
| b2d.body.get_rotational_inertia() | Get the rotational inertia of the body about the local origin. |
| b2d.body.get_shapes() | Get the list of all shapes attached to this body. |
| b2d.body.get_sleep_threshold() | Get the sleep velocity threshold. |
| b2d.body.get_transform() | Get the body transform for the body's origin. |
| b2d.body.get_transform() | Get the body transform for the body's origin. |
| b2d.body.get_type() | Get the type of this body. |
| b2d.body.get_type() | Get the type of this body. |
| b2d.body.get_user_data() | Get the user data pointer that was provided in the body definition. |
| b2d.body.get_world() | Get the parent world of this body. |
| b2d.body.get_world() | Get the parent world of this body. |
| b2d.body.get_world_center() | Get the angle in radians. |
| b2d.body.get_world_center() | Get the world position of the center of mass. |
| b2d.body.get_world_center_of_mass() | Get the world position of the center of mass. |
| b2d.body.get_world_point() | Get the world coordinates of a point given the local coordinates. |
| b2d.body.get_world_point() | Get the world coordinates of a point given the local coordinates. |
| b2d.body.get_world_vector() | Get the world coordinates of a vector given the local coordinates. |
| b2d.body.get_world_vector() | Get the world coordinates of a vector given the local coordinates. |
| b2d.body.is_active() | Get the active state of the body. |
| b2d.body.is_active() | Get the active state of the body. |
| b2d.body.is_awake() | Get the sleeping state of this body. |
| b2d.body.is_awake() | Get the sleeping state of this body. |
| b2d.body.is_bullet() | Is this body in bullet mode |
| b2d.body.is_bullet() | Is this body in bullet mode |
| b2d.body.is_fixed_rotation() | Does this body have fixed rotation? |
| b2d.body.is_fixed_rotation() | Does this body have fixed rotation? |
| b2d.body.is_sleeping_allowed() | Is this body allowed to sleep |
| b2d.body.is_sleeping_enabled() | Is this body allowed to sleep |
| b2d.body.is_valid() | Validate a body handle. |
| b2d.body.reset_mass_data() | This resets the mass properties to the sum of the ... |
| b2d.body.reset_mass_data() | This resets the mass properties to the sum of the ... |
| b2d.body.set_active() | Set the active state of the body |
| b2d.body.set_active() | Set the active state of the body |
| b2d.body.set_angular_damping() | Set the angular damping of the body. |
| b2d.body.set_angular_damping() | Set the angular damping of the body. |
| b2d.body.set_angular_velocity() | Set the angular velocity. |
| b2d.body.set_angular_velocity() | Set the angular velocity. |
| b2d.body.set_awake() | Set the sleep state of the body. A sleeping body has very low CPU cost. |
| b2d.body.set_awake() | Set the sleep state of the body. A sleeping body has very low CPU cost. |
| b2d.body.set_bullet() | Should this body be treated like a bullet for continuous collision detection? |
| b2d.body.set_bullet() | Should this body be treated like a bullet for continuous collision detection? |
| b2d.body.set_fixed_rotation() | Set this body to have fixed rotation. This causes the mass to be reset. |
| b2d.body.set_fixed_rotation() | Set this body to have fixed rotation. This causes the mass to be reset. |
| b2d.body.set_gravity_scale() | Set the gravity scale of the body. |
| b2d.body.set_gravity_scale() | Set the gravity scale of the body. |
| b2d.body.set_linear_damping() | Set the linear damping of the body. |
| b2d.body.set_linear_damping() | Set the linear damping of the body. |
| b2d.body.set_linear_velocity() | Set the linear velocity of the center of mass. |
| b2d.body.set_linear_velocity() | Set the linear velocity of the center of mass. |
| b2d.body.set_mass_data() | Set the mass properties to override the mass prope... |
| b2d.body.set_mass_data() | Set the mass properties to override the mass prope... |
| b2d.body.set_name() | Set the body name. |
| b2d.body.set_sleep_threshold() | Set the sleep velocity threshold. |
| b2d.body.set_sleeping_allowed() | You can disable sleeping on this body. If you disable sleeping, the body will be woken. |
| b2d.body.set_target_transform() | Set velocity to reach a target transform. |
| b2d.body.set_transform() | Set the position of the body's origin and rotation |
| b2d.body.set_transform() | Set the position of the body's origin and rotation |
| b2d.body.set_type() | Set the type of this body. This may alter the mass and velocity. |
| b2d.body.set_type() | Set the type of this body. This may alter the mass and velocity. |
| b2d.body.set_user_data() | Set the user data. Use this to store your application specific data. |
| CONSTANTS | |
|---|---|
| b2d.body.B2_DYNAMIC_BODY | Dynamic body |
| b2d.body.B2_DYNAMIC_BODY | Dynamic body |
| b2d.body.B2_KINEMATIC_BODY | Kinematic body |
| b2d.body.B2_KINEMATIC_BODY | Kinematic body |
| b2d.body.B2_STATIC_BODY | Static (immovable) body |
| b2d.body.B2_STATIC_BODY | Static (immovable) body |
b2d.body.apply_angular_impulse(body,impulse)
Apply an angular impulse.
PARAMETERS
body |
b2Body |
body |
impulse |
number |
impulse the angular impulse in units of kgmm/s |
b2d.body.apply_angular_impulse(body,impulse)
Apply an angular impulse.
PARAMETERS
body |
b2Body |
body |
impulse |
number |
impulse the angular impulse in units of kgmm/s |
b2d.body.apply_force(body,force,point)
Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body.
PARAMETERS
body |
b2Body |
body |
force |
vector3 |
the world force vector, usually in Newtons (N). |
point |
vector3 |
the world position of the point of application. |
b2d.body.apply_force(body,force,point)
Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body.
PARAMETERS
body |
b2Body |
body |
force |
vector3 |
the world force vector, usually in Newtons (N). |
point |
vector3 |
the world position of the point of application. |
b2d.body.apply_force_to_center(body,force)
Apply a force to the center of mass. This wakes up the body.
PARAMETERS
body |
b2Body |
body |
force |
vector3 |
the world force vector, usually in Newtons (N). |
b2d.body.apply_force_to_center(body,force)
Apply a force to the center of mass. This wakes up the body.
PARAMETERS
body |
b2Body |
body |
force |
vector3 |
the world force vector, usually in Newtons (N). |
b2d.body.apply_linear_impulse(body,impulse,point)
Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This wakes up the body.
PARAMETERS
body |
b2Body |
body |
impulse |
vector3 |
the world impulse vector, usually in N-seconds or kg-m/s. |
point |
vector3 |
the world position of the point of application. |
b2d.body.apply_linear_impulse(body,impulse,point)
Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This wakes up the body.
PARAMETERS
body |
b2Body |
body |
impulse |
vector3 |
the world impulse vector, usually in N-seconds or kg-m/s. |
point |
vector3 |
the world position of the point of application. |
b2d.body.apply_linear_impulse_to_center(body,impulse)
Apply a linear impulse to the center of mass.
PARAMETERS
body |
b2Body |
body |
impulse |
vector3 |
world impulse vector |
b2d.body.apply_torque(body,torque)
Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body.
PARAMETERS
body |
b2Body |
body |
torque |
number |
torque about the z-axis (out of the screen), usually in N-m. |
b2d.body.apply_torque(body,torque)
Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body.
PARAMETERS
body |
b2Body |
body |
torque |
number |
torque about the z-axis (out of the screen), usually in N-m. |
b2d.body.compute_aabb(body)
Compute the world AABB of all body shapes.
PARAMETERS
body |
b2Body |
body |
RETURNS
aabb |
table |
table with lower and upper vector3 fields |
b2d.body.create_chain(body,definition)
Chains are one-sided connected segments with optional ghost vertices at the ends of open chains. Ghost vertices are creation-time chain data only and cannot be added to arbitrary shapes, bodies, or joints after creation.
definition.verticesvector3 vertices. Open chains require at least 2 vertices. Loop chains require at least 4 vertices.definition.loopdefinition.prev_vertexdefinition.next_vertexdefinition.frictiondefinition.restitutiondefinition.materialdefinition.filtercategory_bits, mask_bits, and group_index.definition.enable_sensor_eventsPARAMETERS
body |
b2Body |
body |
definition |
table |
the chain definition |
RETURNS
chain |
b2Chain |
created chain handle |
segments |
table |
array of shape info tables for the chain segments |
EXAMPLES
local chain, segments = b2d.body.create_chain(body, {
vertices = {
vmath.vector3(-64, 0, 0),
vmath.vector3(0, 16, 0),
vmath.vector3(64, 0, 0),
},
prev_vertex = vmath.vector3(-96, 0, 0),
next_vertex = vmath.vector3(96, 0, 0),
friction = 0.6,
})
b2d.body.create_fixture(body,definition)
Creates a fixture and attach it to this body. Use this function if you need to set some fixture parameters, like friction. Otherwise you can create the fixture directly from a shape. If the density is non-zero, this function automatically updates the mass of the body. Contacts are not created until the next time step.
PARAMETERS
body |
b2Body |
body |
definition |
table |
fixture definition table with:
shape = shape table, friction = number, restitution = number,
density = number, sensor = boolean, and optional filter table.
Supported shape tables are:
circle = { type = b2d.shape.SHAPE_TYPE_CIRCLE, radius = number, center = vector3_or_nil }
edge = { type = b2d.shape.SHAPE_TYPE_EDGE, v1 = vector3, v2 = vector3, v0 = vector3_or_nil, v3 = vector3_or_nil }
polygon = { type = b2d.shape.SHAPE_TYPE_POLYGON, vertices = { vector3, ... } }
box = { type = b2d.shape.SHAPE_TYPE_BOX, hx = number, hy = number, center = vector3_or_nil, angle = radians_or_nil }
chain = { type = b2d.shape.SHAPE_TYPE_CHAIN, vertices = { vector3, ... }, loop = boolean_or_nil, prev_vertex = vector3_or_nil, next_vertex = vector3_or_nil } |
RETURNS
fixture |
table |
fixture info table with index, type, sensor, density, friction, restitution, and child_count |
EXAMPLES
local body = b2d.get_body("#collisionobject")
local triangle = b2d.body.create_fixture(body, {
density = 1.0,
friction = 0.3,
shape = {
type = b2d.shape.SHAPE_TYPE_POLYGON,
vertices = {
vmath.vector3(-16, -16, 0),
vmath.vector3( 16, -16, 0),
vmath.vector3( 0, 16, 0),
},
},
})
b2d.body.create_fixture(body,shape,density)
Creates a fixture from a shape and attach it to this body. This is a convenience function. Use b2FixtureDef if you need to set parameters like friction, restitution, user data, or filtering. If the density is non-zero, this function automatically updates the mass of the body.
PARAMETERS
body |
b2Body |
body |
shape |
b2Shape |
the shape to be cloned. |
density |
number |
the shape density (set to zero for static bodies). |
b2d.body.create_shape(body,definition)
Creates a shape and attaches it to this body.
If the density is non-zero, this function automatically updates the mass of the body.
Contacts are not created until the next time step.
The definition may include density, friction, restitution, material,
sensor or is_sensor, filter, and the shape table itself. The shape table
can be in definition.shape or directly in definition.
PARAMETERS
body |
b2Body |
body |
definition |
table |
the shape definition. |
b2d.body.destroy_fixture(body,fixture_index)
Destroy a fixture from a body.
PARAMETERS
body |
b2Body |
body |
fixture_index |
number |
1-based fixture index from b2d.body.get_fixtures |
b2d.body.destroy_shape(body,shape_index)
Destroy a shape. This removes the shape from the broad-phase and destroys all contacts associated with this shape. This will automatically adjust the mass of the body if the body is dynamic and the shape has positive density. All shapes attached to a body are implicitly destroyed when the body is destroyed.
PARAMETERS
body |
b2Body |
body |
shape_index |
number |
1-based shape index from b2d.body.get_shapes |
b2d.body.dump(body)
Print the body representation to the log output
PARAMETERS
body |
b2Body |
body |
b2d.body.enable_contact_events(body,enable)
Enable or disable contact events on all body shapes.
PARAMETERS
body |
b2Body |
body |
enable |
boolean |
true to enable contact events |
b2d.body.enable_hit_events(body,enable)
Enable or disable hit events on all body shapes.
PARAMETERS
body |
b2Body |
body |
enable |
boolean |
true to enable hit events |
b2d.body.enable_sleep(body,enable)
You can disable sleeping on this body. If you disable sleeping, the body will be woken.
PARAMETERS
body |
b2Body |
body |
enable |
boolean |
if false, the body will never sleep, and consume more CPU |
b2d.body.get_angle(body)
Get the angle in radians.
PARAMETERS
body |
b2Body |
body |
RETURNS
angle |
number |
the current world rotation angle in radians. |
b2d.body.get_angular_damping(body)
Get the angular damping of the body.
PARAMETERS
body |
b2Body |
body |
RETURNS
damping |
number |
the damping |
b2d.body.get_angular_damping(body)
Get the angular damping of the body.
PARAMETERS
body |
b2Body |
body |
RETURNS
damping |
number |
the damping |
b2d.body.get_angular_velocity(body)
Get the angular velocity.
PARAMETERS
body |
b2Body |
body |
RETURNS
velocity |
number |
the angular velocity in radians/second. |
b2d.body.get_angular_velocity(body)
Get the angular velocity.
PARAMETERS
body |
b2Body |
body |
RETURNS
velocity |
number |
the angular velocity in radians/second. |
b2d.body.get_contact_data(body)
Get touching contact data for a body.
PARAMETERS
body |
b2Body |
body |
RETURNS
contacts |
table |
array of contact tables |
b2d.body.get_contact_list(body)
Get the list of all contacts attached to this body.
PARAMETERS
body |
b2Body |
body |
RETURNS
edge |
b2ContactEdge |
the first edge |
b2d.body.get_contact_list(body)
Get the list of all contacts attached to this body.
PARAMETERS
body |
b2Body |
body |
RETURNS
edge |
b2ContactEdge |
the first edge |
b2d.body.get_fixtures(body)
Get the fixtures attached to this body.
PARAMETERS
body |
b2Body |
body |
RETURNS
fixtures |
table |
array of fixture info tables with index, type, sensor, density, friction, restitution, and child_count |
b2d.body.get_force(body)
Get the total force currently applied on this object
PARAMETERS
body |
b2Body |
body |
RETURNS
force |
vector3 |
b2d.body.get_force(body)
Get the total force currently applied on this object
PARAMETERS
body |
b2Body |
body |
RETURNS
force |
vector3 |
b2d.body.get_gravity_scale(body)
Get the gravity scale of the body.
PARAMETERS
body |
b2Body |
body |
RETURNS
scale |
number |
the scale |
b2d.body.get_gravity_scale(body)
Get the gravity scale of the body.
PARAMETERS
body |
b2Body |
body |
RETURNS
scale |
number |
the scale |
b2d.body.get_inertia(body)
Get the rotational inertia of the body about the local origin.
PARAMETERS
body |
b2Body |
body |
RETURNS
inertia |
number |
the rotational inertia, usually in kg-m^2. |
b2d.body.get_joints(body)
Get the joints attached to this body.
PARAMETERS
body |
b2Body |
body |
RETURNS
joints |
table |
array of b2Joint handles created by b2d.joint |
b2d.body.get_joints(body)
Get the joints attached to this body.
PARAMETERS
body |
b2Body |
body |
RETURNS
joints |
table |
array of b2Joint handles created by b2d.joint |
b2d.body.get_linear_damping(body)
Get the linear damping of the body.
PARAMETERS
body |
b2Body |
body |
RETURNS
damping |
number |
the damping |
b2d.body.get_linear_damping(body)
Get the linear damping of the body.
PARAMETERS
body |
b2Body |
body |
RETURNS
damping |
number |
the damping |
b2d.body.get_linear_velocity(body)
Get the linear velocity of the center of mass.
PARAMETERS
body |
b2Body |
body |
RETURNS
velocity |
vector3 |
the linear velocity of the center of mass. |
b2d.body.get_linear_velocity(body)
Get the linear velocity of the center of mass.
PARAMETERS
body |
b2Body |
body |
RETURNS
velocity |
vector3 |
the linear velocity of the center of mass. |
b2d.body.get_linear_velocity_from_local_point(body,local_point)
Get the world velocity of a local point.
PARAMETERS
body |
b2Body |
body |
local_point |
vector3 |
a point in local coordinates. |
RETURNS
velocity |
vector3 |
the world velocity of a point. |
b2d.body.get_linear_velocity_from_local_point(body,local_point)
Get the world velocity of a local point.
PARAMETERS
body |
b2Body |
body |
local_point |
vector3 |
a point in local coordinates. |
RETURNS
velocity |
vector3 |
the world velocity of a point. |
b2d.body.get_linear_velocity_from_world_point(body,world_point)
Get the world linear velocity of a world point attached to this body.
PARAMETERS
body |
b2Body |
body |
world_point |
vector3 |
a point in world coordinates. |
RETURNS
velocity |
vector3 |
the world velocity of a point. |
b2d.body.get_linear_velocity_from_world_point(body,world_point)
Get the world linear velocity of a world point attached to this body.
PARAMETERS
body |
b2Body |
body |
world_point |
vector3 |
a point in world coordinates. |
RETURNS
velocity |
vector3 |
the world velocity of a point. |
b2d.body.get_local_center(body)
Get the local position of the center of mass.
PARAMETERS
body |
b2Body |
body |
RETURNS
center |
vector3 |
Get the local position of the center of mass. |
b2d.body.get_local_center_of_mass(body)
Get the local position of the center of mass.
PARAMETERS
body |
b2Body |
body |
RETURNS
center |
vector3 |
Get the local position of the center of mass. |
b2d.body.get_local_point(body,world_point)
Gets a local point relative to the body's origin given a world point.
PARAMETERS
body |
b2Body |
body |
world_point |
vector3 |
a point in world coordinates. |
RETURNS
vector |
vector3 |
the corresponding local point relative to the body's origin. |
b2d.body.get_local_point(body,world_point)
Gets a local point relative to the body's origin given a world point.
PARAMETERS
body |
b2Body |
body |
world_point |
vector3 |
a point in world coordinates. |
RETURNS
vector |
vector3 |
the corresponding local point relative to the body's origin. |
b2d.body.get_local_vector(body,world_vector)
Gets a local vector given a world vector.
PARAMETERS
body |
b2Body |
body |
world_vector |
vector3 |
a vector in world coordinates. |
RETURNS
vector |
vector3 |
the corresponding local vector. |
b2d.body.get_local_vector(body,world_vector)
Gets a local vector given a world vector.
PARAMETERS
body |
b2Body |
body |
world_vector |
vector3 |
a vector in world coordinates. |
RETURNS
vector |
vector3 |
the corresponding local vector. |
b2d.body.get_mass(body)
Get the total mass of the body.
PARAMETERS
body |
b2Body |
body |
RETURNS
mass |
number |
the mass, usually in kilograms (kg). |
b2d.body.get_mass(body)
Get the total mass of the body.
PARAMETERS
body |
b2Body |
body |
RETURNS
mass |
number |
the mass, usually in kilograms (kg). |
b2d.body.get_mass_data(body)
Get the mass data of the body.
PARAMETERS
body |
b2Body |
body |
RETURNS
data |
table |
table with mass, center in local coordinates, and inertia. |
b2d.body.get_mass_data(body)
Get the mass data of the body.
PARAMETERS
body |
b2Body |
body |
RETURNS
data |
b2MassData |
a struct containing the mass, inertia and center of the body. |
b2d.body.get_name(body)
Get the body name.
PARAMETERS
body |
b2Body |
body |
RETURNS
name |
string |
body name, or nil if no name is set |
b2d.body.get_next(body)
Get the next body in the world's body list.
PARAMETERS
body |
b2Body |
body |
RETURNS
body |
b2Body |
the next body |
b2d.body.get_position(body)
Get the world body origin position.
PARAMETERS
body |
b2Body |
body |
RETURNS
position |
vector3 |
the world position of the body's origin. |
b2d.body.get_position(body)
Get the world body origin position.
PARAMETERS
body |
b2Body |
body |
RETURNS
position |
vector3 |
the world position of the body's origin. |
b2d.body.get_rotational_inertia(body)
Get the rotational inertia of the body about the local origin.
PARAMETERS
body |
b2Body |
body |
RETURNS
inertia |
number |
the rotational inertia, usually in kg-m^2. |
b2d.body.get_shapes(body)
Get the list of all shapes attached to this body.
PARAMETERS
body |
b2Body |
body |
RETURNS
shapes |
table |
a table of shape info entries. Each entry includes shape_id for use with b2d.shape functions. |
b2d.body.get_sleep_threshold(body)
Get the sleep velocity threshold.
PARAMETERS
body |
b2Body |
body |
RETURNS
threshold |
number |
velocity threshold in Defold units per second |
b2d.body.get_transform(body)
Get the body transform for the body's origin.
PARAMETERS
body |
b2Body |
body |
RETURNS
transform |
table |
table with position and angle in radians. |
b2d.body.get_transform(body)
Get the body transform for the body's origin.
PARAMETERS
body |
b2Body |
body |
RETURNS
transform |
b2Transform |
the world position of the body's origin. |
b2d.body.get_type(body)
Get the type of this body.
PARAMETERS
body |
b2Body |
body |
RETURNS
type |
b2BodyType |
the body type |
b2d.body.get_type(body)
Get the type of this body.
PARAMETERS
body |
b2Body |
body |
RETURNS
type |
b2BodyType |
the body type |
b2d.body.get_user_data(body)
Get the user data pointer that was provided in the body definition.
PARAMETERS
body |
b2Body |
body |
RETURNS
id |
hash |
the game object id this body is connected to |
b2d.body.get_world(body)
Get the parent world of this body.
PARAMETERS
body |
b2Body |
body |
RETURNS
world |
b2World |
b2d.body.get_world(body)
Get the parent world of this body.
PARAMETERS
body |
b2Body |
body |
RETURNS
world |
b2World |
b2d.body.get_world_center(body)
Get the angle in radians.
PARAMETERS
body |
b2Body |
body |
RETURNS
angle |
number |
the current world rotation angle in radians. |
b2d.body.get_world_center(body)
Get the world position of the center of mass.
PARAMETERS
body |
b2Body |
body |
RETURNS
center |
vector3 |
Get the world position of the center of mass. |
b2d.body.get_world_center_of_mass(body)
Get the world position of the center of mass.
PARAMETERS
body |
b2Body |
body |
RETURNS
center |
vector3 |
Get the world position of the center of mass. |
b2d.body.get_world_point(body,local_vector)
Get the world coordinates of a point given the local coordinates.
PARAMETERS
body |
b2Body |
body |
local_vector |
vector3 |
localPoint a point on the body measured relative the the body's origin. |
RETURNS
vector |
vector3 |
the same point expressed in world coordinates. |
b2d.body.get_world_point(body,local_vector)
Get the world coordinates of a point given the local coordinates.
PARAMETERS
body |
b2Body |
body |
local_vector |
vector3 |
localPoint a point on the body measured relative the the body's origin. |
RETURNS
vector |
vector3 |
the same point expressed in world coordinates. |
b2d.body.get_world_vector(body,local_vector)
Get the world coordinates of a vector given the local coordinates.
PARAMETERS
body |
b2Body |
body |
local_vector |
vector3 |
a vector fixed in the body. |
RETURNS
vector |
vector3 |
the same vector expressed in world coordinates. |
b2d.body.get_world_vector(body,local_vector)
Get the world coordinates of a vector given the local coordinates.
PARAMETERS
body |
b2Body |
body |
local_vector |
vector3 |
a vector fixed in the body. |
RETURNS
vector |
vector3 |
the same vector expressed in world coordinates. |
b2d.body.is_active(body)
Get the active state of the body.
PARAMETERS
body |
b2Body |
body |
RETURNS
enabled |
boolean |
is the body active |
b2d.body.is_active(body)
Get the active state of the body.
PARAMETERS
body |
b2Body |
body |
RETURNS
enabled |
boolean |
is the body active |
b2d.body.is_awake(body)
Get the sleeping state of this body.
PARAMETERS
body |
b2Body |
body |
RETURNS
enabled |
boolean |
true if the body is awake, false if it's sleeping. |
b2d.body.is_awake(body)
Get the sleeping state of this body.
PARAMETERS
body |
b2Body |
body |
RETURNS
enabled |
boolean |
true if the body is awake, false if it's sleeping. |
b2d.body.is_bullet(body)
Is this body in bullet mode
PARAMETERS
body |
b2Body |
body |
RETURNS
enabled |
boolean |
true if the body is in bullet mode |
b2d.body.is_bullet(body)
Is this body in bullet mode
PARAMETERS
body |
b2Body |
body |
RETURNS
enabled |
boolean |
true if the body is in bullet mode |
b2d.body.is_fixed_rotation(body)
Does this body have fixed rotation?
PARAMETERS
body |
b2Body |
body |
RETURNS
enabled |
boolean |
is the rotation fixed |
b2d.body.is_fixed_rotation(body)
Does this body have fixed rotation?
PARAMETERS
body |
b2Body |
body |
RETURNS
enabled |
boolean |
is the rotation fixed |
b2d.body.is_sleeping_allowed(body)
Is this body allowed to sleep
PARAMETERS
body |
b2Body |
body |
RETURNS
enabled |
boolean |
true if the body is allowed to sleep |
b2d.body.is_sleeping_enabled(body)
Is this body allowed to sleep
PARAMETERS
body |
b2Body |
body |
RETURNS
enabled |
boolean |
true if the body is allowed to sleep |
b2d.body.is_valid(body)
Validate a body handle.
PARAMETERS
body |
b2Body |
body |
RETURNS
valid |
boolean |
true if the body handle still refers to a live Box2D body |
b2d.body.reset_mass_data(body)
This resets the mass properties to the sum of the mass properties of the fixtures. This normally does not need to be called unless you called SetMassData to override
PARAMETERS
body |
b2Body |
body |
b2d.body.reset_mass_data(body)
This resets the mass properties to the sum of the mass properties of the shapes. This normally does not need to be called unless you called SetMassData to override
PARAMETERS
body |
b2Body |
body |
b2d.body.set_active(body,enable)
Set the active state of the body. An inactive body is not simulated and cannot be collided with or woken up. If you pass a flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false, all fixtures will be removed from the broad-phase and all contacts will be destroyed. Fixtures and joints are otherwise unaffected. You may continue to create/destroy fixtures and joints on inactive bodies. Fixtures on an inactive body are implicitly inactive and will not participate in collisions, ray-casts, or queries. Joints connected to an inactive body are implicitly inactive. An inactive body is still owned by a b2World object and remains in the body list.
PARAMETERS
body |
b2Body |
body |
enable |
boolean |
true if the body should be active |
b2d.body.set_active(body,enable)
Set the active state of the body. An inactive body is not simulated and cannot be collided with or woken up. If you pass a flag of true, all shapes will be added to the broad-phase. If you pass a flag of false, all shapes will be removed from the broad-phase and all contacts will be destroyed. Shapes and joints are otherwise unaffected. You may continue to create/destroy shapes and joints on inactive bodies. Shapes on an inactive body are implicitly inactive and will not participate in collisions, ray-casts, or queries. Joints connected to an inactive body are implicitly inactive. An inactive body is still owned by a b2World object and remains in the body list.
PARAMETERS
body |
b2Body |
body |
enable |
boolean |
true if the body should be active |
b2d.body.set_angular_damping(body,damping)
Set the angular damping of the body.
PARAMETERS
body |
b2Body |
body |
damping |
number |
the damping |
b2d.body.set_angular_damping(body,damping)
Set the angular damping of the body.
PARAMETERS
body |
b2Body |
body |
damping |
number |
the damping |
b2d.body.set_angular_velocity(body,omega)
Set the angular velocity.
PARAMETERS
body |
b2Body |
body |
omega |
number |
the new angular velocity in radians/second. |
b2d.body.set_angular_velocity(body,omega)
Set the angular velocity.
PARAMETERS
body |
b2Body |
body |
omega |
number |
the new angular velocity in radians/second. |
b2d.body.set_awake(body,enable)
Set the sleep state of the body. A sleeping body has very low CPU cost.
PARAMETERS
body |
b2Body |
body |
enable |
boolean |
flag set to false to put body to sleep, true to wake it. |
b2d.body.set_awake(body,enable)
Set the sleep state of the body. A sleeping body has very low CPU cost.
PARAMETERS
body |
b2Body |
body |
enable |
boolean |
flag set to false to put body to sleep, true to wake it. |
b2d.body.set_bullet(body,enable)
Should this body be treated like a bullet for continuous collision detection?
PARAMETERS
body |
b2Body |
body |
enable |
boolean |
if true, the body will be in bullet mode |
b2d.body.set_bullet(body,enable)
Should this body be treated like a bullet for continuous collision detection?
PARAMETERS
body |
b2Body |
body |
enable |
boolean |
if true, the body will be in bullet mode |
b2d.body.set_fixed_rotation(body,enable)
Set this body to have fixed rotation. This causes the mass to be reset.
PARAMETERS
body |
b2Body |
body |
enable |
boolean |
true if the rotation should be fixed |
b2d.body.set_fixed_rotation(body,enable)
Set this body to have fixed rotation. This causes the mass to be reset.
PARAMETERS
body |
b2Body |
body |
enable |
boolean |
true if the rotation should be fixed |
b2d.body.set_gravity_scale(body,scale)
Set the gravity scale of the body.
PARAMETERS
body |
b2Body |
body |
scale |
number |
the scale |
b2d.body.set_gravity_scale(body,scale)
Set the gravity scale of the body.
PARAMETERS
body |
b2Body |
body |
scale |
number |
the scale |
b2d.body.set_linear_damping(body,damping)
Set the linear damping of the body.
PARAMETERS
body |
b2Body |
body |
damping |
number |
the damping |
b2d.body.set_linear_damping(body,damping)
Set the linear damping of the body.
PARAMETERS
body |
b2Body |
body |
damping |
number |
the damping |
b2d.body.set_linear_velocity(body,velocity)
Set the linear velocity of the center of mass.
PARAMETERS
body |
b2Body |
body |
velocity |
vector3 |
the new linear velocity of the center of mass. |
b2d.body.set_linear_velocity(body,velocity)
Set the linear velocity of the center of mass.
PARAMETERS
body |
b2Body |
body |
velocity |
vector3 |
the new linear velocity of the center of mass. |
b2d.body.set_mass_data(body,data)
Set the mass properties to override the mass properties of the fixtures.
PARAMETERS
body |
b2Body |
body |
data |
table |
table with mass, center in local coordinates, and inertia. |
b2d.body.set_mass_data(body,data)
Set the mass properties to override the mass properties of the shapes.
PARAMETERS
body |
b2Body |
body |
data |
b2MassData |
the mass properties. |
b2d.body.set_name(body,name)
Set the body name.
PARAMETERS
body |
b2Body |
body |
name |
string |
body name |
b2d.body.set_sleep_threshold(body,threshold)
Set the sleep velocity threshold.
PARAMETERS
body |
b2Body |
body |
threshold |
number |
velocity threshold in Defold units per second |
b2d.body.set_sleeping_allowed(body,enable)
You can disable sleeping on this body. If you disable sleeping, the body will be woken.
PARAMETERS
body |
b2Body |
body |
enable |
boolean |
if false, the body will never sleep, and consume more CPU |
b2d.body.set_target_transform(body,position,angle,time_step)
Set velocity to reach a target transform.
PARAMETERS
body |
b2Body |
body |
position |
vector3 |
target world position |
angle |
number |
target world angle in radians |
time_step |
number |
time step used to compute velocity |
b2d.body.set_transform(body,position,angle)
Set the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior.
PARAMETERS
body |
b2Body |
body |
position |
vector3 |
the world position of the body's local origin. |
angle |
number |
the world position of the body's local origin. |
b2d.body.set_transform(body,position,angle)
Set the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior.
PARAMETERS
body |
b2Body |
body |
position |
vector3 |
the world position of the body's local origin. |
angle |
number |
the world position of the body's local origin. |
b2d.body.set_type(body,type)
Set the type of this body. This may alter the mass and velocity.
PARAMETERS
body |
b2Body |
body |
type |
b2BodyType |
the body type |
b2d.body.set_type(body,type)
Set the type of this body. This may alter the mass and velocity.
PARAMETERS
body |
b2Body |
body |
type |
b2BodyType |
the body type |
b2d.body.set_user_data(body,id)
Set the user data. Use this to store your application specific data.
PARAMETERS
body |
b2Body |
body |
id |
hash |
the game object id |