Namespace: b2d.body
Language: Lua
Type: Defold Lua
File: script_box2d_body.cpp
Source: engine/gamesys/src/gamesys/scripts/box2d/script_box2d_body.cpp
Functions for interacting with Box2D bodies.
Type: TYPEDEF Box2D body
Parameters
value (userdata)Type: FUNCTION Apply an angular impulse.
Parameters
body (b2Body) - bodyimpulse (number) - impulse the angular impulse in units of kgmm/sType: FUNCTION Apply an angular impulse.
Parameters
body (b2Body) - bodyimpulse (number) - impulse the angular impulse in units of kgmm/sType: FUNCTION 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) - bodyforce (vector3) - the world force vector, usually in Newtons (N).point (vector3) - the world position of the point of application.Type: FUNCTION 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) - bodyforce (vector3) - the world force vector, usually in Newtons (N).point (vector3) - the world position of the point of application.Type: FUNCTION Apply a force to the center of mass. This wakes up the body.
Parameters
body (b2Body) - bodyforce (vector3) - the world force vector, usually in Newtons (N).Type: FUNCTION Apply a force to the center of mass. This wakes up the body.
Parameters
body (b2Body) - bodyforce (vector3) - the world force vector, usually in Newtons (N).Type: FUNCTION 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) - bodyimpulse (vector3) - the world impulse vector, usually in N-seconds or kg-m/s.point (vector3) - the world position of the point of application.Type: FUNCTION 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) - bodyimpulse (vector3) - the world impulse vector, usually in N-seconds or kg-m/s.point (vector3) - the world position of the point of application.Type: FUNCTION 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) - bodytorque (number) - torque about the z-axis (out of the screen), usually in N-m.Type: FUNCTION 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) - bodytorque (number) - torque about the z-axis (out of the screen), usually in N-m.Type: CONSTANT Dynamic body
Type: CONSTANT Dynamic body
Type: CONSTANT Kinematic body
Type: CONSTANT Kinematic body
Type: CONSTANT Static (immovable) body
Type: CONSTANT Static (immovable) body
Type: FUNCTION Print the body representation to the log output
Parameters
body (b2Body) - bodyType: FUNCTION You can disable sleeping on this body. If you disable sleeping, the body will be woken.
Parameters
body (b2Body) - bodyenable (boolean) - if false, the body will never sleep, and consume more CPUType: FUNCTION Get the angle in radians.
Parameters
body (b2Body) - bodyReturns
angle (number) - the current world rotation angle in radians.Type: FUNCTION Get the angular damping of the body.
Parameters
body (b2Body) - bodyReturns
damping (number) - the dampingType: FUNCTION Get the angular damping of the body.
Parameters
body (b2Body) - bodyReturns
damping (number) - the dampingType: FUNCTION Get the angular velocity.
Parameters
body (b2Body) - bodyReturns
velocity (number) - the angular velocity in radians/second.Type: FUNCTION Get the angular velocity.
Parameters
body (b2Body) - bodyReturns
velocity (number) - the angular velocity in radians/second.Type: FUNCTION Get the gravity scale of the body.
Parameters
body (b2Body) - bodyReturns
scale (number) - the scaleType: FUNCTION Get the gravity scale of the body.
Parameters
body (b2Body) - bodyReturns
scale (number) - the scaleType: FUNCTION Get the rotational inertia of the body about the local origin.
Parameters
body (b2Body) - bodyReturns
inertia (number) - the rotational inertia, usually in kg-m^2.Type: FUNCTION Get the linear damping of the body.
Parameters
body (b2Body) - bodyReturns
damping (number) - the dampingType: FUNCTION Get the linear damping of the body.
Parameters
body (b2Body) - bodyReturns
damping (number) - the dampingType: FUNCTION Get the linear velocity of the center of mass.
Parameters
body (b2Body) - bodyReturns
velocity (vector3) - the linear velocity of the center of mass.Type: FUNCTION Get the linear velocity of the center of mass.
Parameters
body (b2Body) - bodyReturns
velocity (vector3) - the linear velocity of the center of mass.Type: FUNCTION Get the world velocity of a local point.
Parameters
body (b2Body) - bodylocal_point (vector3) - a point in local coordinates.Returns
velocity (vector3) - the world velocity of a point.Type: FUNCTION Get the world velocity of a local point.
Parameters
body (b2Body) - bodylocal_point (vector3) - a point in local coordinates.Returns
velocity (vector3) - the world velocity of a point.Type: FUNCTION Get the world linear velocity of a world point attached to this body.
Parameters
body (b2Body) - bodyworld_point (vector3) - a point in world coordinates.Returns
velocity (vector3) - the world velocity of a point.Type: FUNCTION Get the world linear velocity of a world point attached to this body.
Parameters
body (b2Body) - bodyworld_point (vector3) - a point in world coordinates.Returns
velocity (vector3) - the world velocity of a point.Type: FUNCTION Get the local position of the center of mass.
Parameters
body (b2Body) - bodyReturns
center (vector3) - Get the local position of the center of mass.Type: FUNCTION Get the local position of the center of mass.
Parameters
body (b2Body) - bodyReturns
center (vector3) - Get the local position of the center of mass.Type: FUNCTION Gets a local point relative to the body’s origin given a world point.
Parameters
body (b2Body) - bodyworld_point (vector3) - a point in world coordinates.Returns
vector (vector3) - the corresponding local point relative to the body’s origin.Type: FUNCTION Gets a local point relative to the body’s origin given a world point.
Parameters
body (b2Body) - bodyworld_point (vector3) - a point in world coordinates.Returns
vector (vector3) - the corresponding local point relative to the body’s origin.Type: FUNCTION Gets a local vector given a world vector.
Parameters
body (b2Body) - bodyworld_vector (vector3) - a vector in world coordinates.Returns
vector (vector3) - the corresponding local vector.Type: FUNCTION Gets a local vector given a world vector.
Parameters
body (b2Body) - bodyworld_vector (vector3) - a vector in world coordinates.Returns
vector (vector3) - the corresponding local vector.Type: FUNCTION Get the total mass of the body.
Parameters
body (b2Body) - bodyReturns
mass (number) - the mass, usually in kilograms (kg).Type: FUNCTION Get the total mass of the body.
Parameters
body (b2Body) - bodyReturns
mass (number) - the mass, usually in kilograms (kg).Type: FUNCTION Get the next body in the world’s body list.
Parameters
body (b2Body) - bodyReturns
body (b2Body) - the next bodyType: FUNCTION Get the world body origin position.
Parameters
body (b2Body) - bodyReturns
position (vector3) - the world position of the body’s origin.Type: FUNCTION Get the world body origin position.
Parameters
body (b2Body) - bodyReturns
position (vector3) - the world position of the body’s origin.Type: FUNCTION Get the rotational inertia of the body about the local origin.
Parameters
body (b2Body) - bodyReturns
inertia (number) - the rotational inertia, usually in kg-m^2.Type: FUNCTION Get the type of this body.
Parameters
body (b2Body) - bodyReturns
type (b2BodyType) - the body typeType: FUNCTION Get the type of this body.
Parameters
body (b2Body) - bodyReturns
type (b2BodyType) - the body typeType: FUNCTION Get the parent world of this body.
Parameters
body (b2Body) - bodyReturns
world (b2World)Type: FUNCTION Get the parent world of this body.
Parameters
body (b2Body) - bodyReturns
world (b2World)Type: FUNCTION Get the angle in radians.
Parameters
body (b2Body) - bodyReturns
angle (number) - the current world rotation angle in radians.Type: FUNCTION Get the world position of the center of mass.
Parameters
body (b2Body) - bodyReturns
center (vector3) - Get the world position of the center of mass.Type: FUNCTION Get the world position of the center of mass.
Parameters
body (b2Body) - bodyReturns
center (vector3) - Get the world position of the center of mass.Type: FUNCTION Get the world coordinates of a point given the local coordinates.
Parameters
body (b2Body) - bodylocal_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.Type: FUNCTION Get the world coordinates of a point given the local coordinates.
Parameters
body (b2Body) - bodylocal_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.Type: FUNCTION Get the world coordinates of a vector given the local coordinates.
Parameters
body (b2Body) - bodylocal_vector (vector3) - a vector fixed in the body.Returns
vector (vector3) - the same vector expressed in world coordinates.Type: FUNCTION Get the world coordinates of a vector given the local coordinates.
Parameters
body (b2Body) - bodylocal_vector (vector3) - a vector fixed in the body.Returns
vector (vector3) - the same vector expressed in world coordinates.Type: FUNCTION Get the active state of the body.
Parameters
body (b2Body) - bodyReturns
enabled (boolean) - is the body activeType: FUNCTION Get the active state of the body.
Parameters
body (b2Body) - bodyReturns
enabled (boolean) - is the body activeType: FUNCTION Get the sleeping state of this body.
Parameters
body (b2Body) - bodyReturns
enabled (boolean) - true if the body is awake, false if it’s sleeping.Type: FUNCTION Get the sleeping state of this body.
Parameters
body (b2Body) - bodyReturns
enabled (boolean) - true if the body is awake, false if it’s sleeping.Type: FUNCTION Is this body in bullet mode
Parameters
body (b2Body) - bodyReturns
enabled (boolean) - true if the body is in bullet modeType: FUNCTION Is this body in bullet mode
Parameters
body (b2Body) - bodyReturns
enabled (boolean) - true if the body is in bullet modeType: FUNCTION Does this body have fixed rotation?
Parameters
body (b2Body) - bodyReturns
enabled (boolean) - is the rotation fixedType: FUNCTION Does this body have fixed rotation?
Parameters
body (b2Body) - bodyReturns
enabled (boolean) - is the rotation fixedType: FUNCTION Is this body allowed to sleep
Parameters
body (b2Body) - bodyReturns
enabled (boolean) - true if the body is allowed to sleepType: FUNCTION Is this body allowed to sleep
Parameters
body (b2Body) - bodyReturns
enabled (boolean) - true if the body is allowed to sleepType: FUNCTION 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) - bodyType: FUNCTION 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) - bodyType: FUNCTION 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) - bodyenable (boolean) - true if the body should be activeType: FUNCTION 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) - bodyenable (boolean) - true if the body should be activeType: FUNCTION Set the angular damping of the body.
Parameters
body (b2Body) - bodydamping (number) - the dampingType: FUNCTION Set the angular damping of the body.
Parameters
body (b2Body) - bodydamping (number) - the dampingType: FUNCTION Set the angular velocity.
Parameters
body (b2Body) - bodyomega (number) - the new angular velocity in radians/second.Type: FUNCTION Set the angular velocity.
Parameters
body (b2Body) - bodyomega (number) - the new angular velocity in radians/second.Type: FUNCTION Set the sleep state of the body. A sleeping body has very low CPU cost.
Parameters
body (b2Body) - bodyenable (boolean) - flag set to false to put body to sleep, true to wake it.Type: FUNCTION Set the sleep state of the body. A sleeping body has very low CPU cost.
Parameters
body (b2Body) - bodyenable (boolean) - flag set to false to put body to sleep, true to wake it.Type: FUNCTION Should this body be treated like a bullet for continuous collision detection?
Parameters
body (b2Body) - bodyenable (boolean) - if true, the body will be in bullet modeType: FUNCTION Should this body be treated like a bullet for continuous collision detection?
Parameters
body (b2Body) - bodyenable (boolean) - if true, the body will be in bullet modeType: FUNCTION Set this body to have fixed rotation. This causes the mass to be reset.
Parameters
body (b2Body) - bodyenable (boolean) - true if the rotation should be fixedType: FUNCTION Set this body to have fixed rotation. This causes the mass to be reset.
Parameters
body (b2Body) - bodyenable (boolean) - true if the rotation should be fixedType: FUNCTION Set the gravity scale of the body.
Parameters
body (b2Body) - bodyscale (number) - the scaleType: FUNCTION Set the gravity scale of the body.
Parameters
body (b2Body) - bodyscale (number) - the scaleType: FUNCTION Set the linear damping of the body.
Parameters
body (b2Body) - bodydamping (number) - the dampingType: FUNCTION Set the linear damping of the body.
Parameters
body (b2Body) - bodydamping (number) - the dampingType: FUNCTION Set the linear velocity of the center of mass.
Parameters
body (b2Body) - bodyvelocity (vector3) - the new linear velocity of the center of mass.Type: FUNCTION Set the linear velocity of the center of mass.
Parameters
body (b2Body) - bodyvelocity (vector3) - the new linear velocity of the center of mass.Type: FUNCTION You can disable sleeping on this body. If you disable sleeping, the body will be woken.
Parameters
body (b2Body) - bodyenable (boolean) - if false, the body will never sleep, and consume more CPUType: FUNCTION 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) - bodyposition (vector3) - the world position of the body’s local origin.angle (number) - the world position of the body’s local origin.Type: FUNCTION 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) - bodyposition (vector3) - the world position of the body’s local origin.angle (number) - the world position of the body’s local origin.Type: FUNCTION Set the type of this body. This may alter the mass and velocity.
Parameters
body (b2Body) - bodytype (b2BodyType) - the body typeType: FUNCTION Set the type of this body. This may alter the mass and velocity.
Parameters
body (b2Body) - bodytype (b2BodyType) - the body typeType: TYPEDEF Box2D world
Parameters
value (userdata)