Defold Learn logo


Bullet constraint API

Creates and controls Bullet constraints between Defold rigid bodies. A constraint belongs to the supplied world and is destroyed automatically with either body, with the world, or when the module is finalized. It is temporarily removed from the native world while either linked body is disabled and is restored when both bodies are enabled again. Dropping its Lua userdata does not destroy the native constraint; call destroy for early release.

Creator positions and all other linear values use Defold units and are converted with physics.scale. Angles are radians. Axes are one-based in Lua: axes 1-3 are linear and axes 4-6 are angular. Mutating functions cannot be called while the physics world is stepping.

CONSTRAINT_TYPE_* values identify the concrete constraint exposed by this binding. This deliberately distinguishes universal, hinge2, and spring 6-DOF constraints even though Bullet 2.77 reports their native base type as 6-DOF.

Version: alpha

FUNCTIONS
bullet3d.constraint.create_cone_twist() Create a cone-twist constraint
bullet3d.constraint.create_generic_6dof() Create a generic six-degree-of-freedom constraint
bullet3d.constraint.create_generic_6dof_spring() Create a generic spring six-degree-of-freedom constraint
bullet3d.constraint.create_hinge() Create a hinge constraint
bullet3d.constraint.create_hinge2() Create a hinge2 constraint
bullet3d.constraint.create_point_to_point() Create a point-to-point constraint
bullet3d.constraint.create_slider() Create a slider constraint
bullet3d.constraint.create_universal() Create a universal constraint
bullet3d.constraint.destroy() Destroy a constraint
bullet3d.constraint.enable_cone_twist_motor() Enable or disable the cone-twist motor
bullet3d.constraint.enable_spring() Enable or disable a spring axis
bullet3d.constraint.get_6dof_angle() Get a current 6-DOF angle
bullet3d.constraint.get_6dof_axis() Get a current 6-DOF angular axis
bullet3d.constraint.get_6dof_motor() Get 6-DOF motor settings
bullet3d.constraint.get_6dof_position() Get a current 6-DOF linear position
bullet3d.constraint.get_anchors() Get universal or hinge2 anchors
bullet3d.constraint.get_angles() Get universal or hinge2 angles
bullet3d.constraint.get_axes() Get universal or hinge2 axes
bullet3d.constraint.get_body_a() Get the first linked body
bullet3d.constraint.get_body_b() Get the second linked body
bullet3d.constraint.get_collide_connected() Get whether connected bodies can collide
bullet3d.constraint.get_cone_twist_limits() Get cone-twist angular spans
bullet3d.constraint.get_frame_a() Get local frame A
bullet3d.constraint.get_frame_b() Get local frame B
bullet3d.constraint.get_hinge_angle() Get the current hinge angle
bullet3d.constraint.get_hinge_limits() Get hinge angular limits
bullet3d.constraint.get_hinge_motor() Get hinge motor settings
bullet3d.constraint.get_limit() Get a 6-DOF axis limit
bullet3d.constraint.get_pivots() Get point-to-point pivots
bullet3d.constraint.get_slider_limits() Get slider limits
bullet3d.constraint.get_slider_motor() Get slider motor settings
bullet3d.constraint.get_slider_position() Get the current slider position
bullet3d.constraint.get_twist_angle() Get the current cone-twist twist angle
bullet3d.constraint.get_type() Get the constraint type
bullet3d.constraint.get_type_name() Get the constraint type name
bullet3d.constraint.get_use_linear_reference_frame_a() Get the slider linear reference-frame choice
bullet3d.constraint.get_world() Get the owning world
bullet3d.constraint.is_active() Test whether a constraint is active in its world
bullet3d.constraint.is_angular_only() Test angular-only mode
bullet3d.constraint.is_limited() Test whether a 6-DOF axis is limited
bullet3d.constraint.is_past_swing_limit() Test whether a cone-twist is past its swing limit
bullet3d.constraint.is_valid() Test whether a constraint handle is valid
bullet3d.constraint.set_6dof_motor() Set 6-DOF motor settings
bullet3d.constraint.set_angular_only() Set angular-only mode
bullet3d.constraint.set_cone_twist_limits() Set cone-twist angular spans
bullet3d.constraint.set_cone_twist_motor_target() Set the cone-twist motor target
bullet3d.constraint.set_frame_a() Set local frame A
bullet3d.constraint.set_frame_b() Set local frame B
bullet3d.constraint.set_hinge_axis() Set the one-body hinge axis
bullet3d.constraint.set_hinge_limits() Set hinge angular limits
bullet3d.constraint.set_hinge_motor() Set hinge motor settings
bullet3d.constraint.set_hinge_motor_target() Set a hinge motor angle target
bullet3d.constraint.set_limit() Set a 6-DOF axis limit
bullet3d.constraint.set_pivots() Set point-to-point pivots
bullet3d.constraint.set_slider_limits() Set slider limits
bullet3d.constraint.set_slider_motor() Set slider motor settings
bullet3d.constraint.set_spring_damping() Set spring damping
bullet3d.constraint.set_spring_equilibrium_point() Set spring equilibrium points
bullet3d.constraint.set_spring_stiffness() Set spring stiffness
CONSTANTS
bullet3d.constraint.CONSTRAINT_TYPE_CONE_TWIST Cone-twist constraint type
bullet3d.constraint.CONSTRAINT_TYPE_GENERIC_6DOF Generic 6-DOF constraint type
bullet3d.constraint.CONSTRAINT_TYPE_GENERIC_6DOF_SPRING Generic spring 6-DOF constraint type
bullet3d.constraint.CONSTRAINT_TYPE_HINGE Hinge constraint type
bullet3d.constraint.CONSTRAINT_TYPE_HINGE2 Hinge2 constraint type
bullet3d.constraint.CONSTRAINT_TYPE_POINT_TO_POINT Point-to-point constraint type
bullet3d.constraint.CONSTRAINT_TYPE_SLIDER Slider constraint type
bullet3d.constraint.CONSTRAINT_TYPE_UNIVERSAL Universal constraint type

Functions

bullet3d.constraint.create_cone_twist()

bullet3d.constraint.create_cone_twist(body_a,body_b,params)

The params table uses the same local-frame fields as a hinge and optionally accepts angular_only and collide_connected. The world is derived from body_a.

PARAMETERS

body_a btRigidBody
first body
body_b btRigidBody
nil
second body or world
params table
local frames and options

RETURNS

constraint btTypedConstraint
cone-twist constraint

bullet3d.constraint.create_generic_6dof()

bullet3d.constraint.create_generic_6dof(body_a,body_b,params)

The params table requires local frame A and, for a two-body constraint, local frame B. It optionally accepts collide_connected. The world is derived from body_a. Bullet 2.77's active 6-DOF solver ignores its legacy linear-reference-frame selector, so that field is rejected rather than silently accepted.

PARAMETERS

body_a btRigidBody
first body
body_b btRigidBody
nil
second body or world
params table
local frames and options

RETURNS

constraint btTypedConstraint
generic 6-DOF constraint

bullet3d.constraint.create_generic_6dof_spring()

bullet3d.constraint.create_generic_6dof_spring(body_a,body_b,params)

Both bodies and both local frames are required. The params table optionally accepts collide_connected. The world is derived from body_a. Bullet 2.77's active spring 6-DOF solver ignores its legacy linear-reference-frame selector, so that field is rejected rather than silently accepted.

PARAMETERS

body_a btRigidBody
first body
body_b btRigidBody
second body
params table
local frames and options

RETURNS

constraint btTypedConstraint
spring 6-DOF constraint

EXAMPLES

Create a spring that moves along its first linear axis:
function init(self)
    local body_a = bullet3d.get_rigid_body("/body_a#collisionobject")
    local body_b = bullet3d.get_rigid_body("/body_b#collisionobject")
    self.spring = bullet3d.constraint.create_generic_6dof_spring(body_a, body_b, {
        frame_a_position = vmath.vector3(),
        frame_a_rotation = vmath.quat(),
        frame_b_position = vmath.vector3(),
        frame_b_rotation = vmath.quat(),
    })
    bullet3d.constraint.set_limit(self.spring, 1, -1, 1)
    bullet3d.constraint.enable_spring(self.spring, 1, true)
    bullet3d.constraint.set_spring_stiffness(self.spring, 1, 20)
    bullet3d.constraint.set_spring_damping(self.spring, 1, 0.5)
    bullet3d.constraint.set_spring_equilibrium_point(self.spring, 1, 0)
end

function final(self)
    if self.spring and bullet3d.constraint.is_valid(self.spring) then
        bullet3d.constraint.destroy(self.spring)
    end
end

bullet3d.constraint.create_hinge()

bullet3d.constraint.create_hinge(body_a,body_b,params)

The params table requires frame_a_position and frame_a_rotation, plus the corresponding frame B fields for a two-body constraint. It optionally accepts use_reference_frame_a, angular_only, and collide_connected. The world is derived from body_a.

PARAMETERS

body_a btRigidBody
first body
body_b btRigidBody
nil
second body or world
params table
local frames and options

RETURNS

constraint btTypedConstraint
hinge constraint

EXAMPLES

Create a motorized hinge with a 90-degree range:
function init(self)
    local body_a = bullet3d.get_rigid_body("/door#collisionobject")
    local body_b = bullet3d.get_rigid_body("/frame#collisionobject")
    self.hinge = bullet3d.constraint.create_hinge(body_a, body_b, {
        frame_a_position = vmath.vector3(-0.5, 0, 0),
        frame_a_rotation = vmath.quat(),
        frame_b_position = vmath.vector3(0.5, 0, 0),
        frame_b_rotation = vmath.quat(),
    })
    bullet3d.constraint.set_hinge_limits(self.hinge, -math.pi / 4, math.pi / 4)
    bullet3d.constraint.set_hinge_motor(self.hinge, true, 1.5, 2.5)
end

function final(self)
    if self.hinge and bullet3d.constraint.is_valid(self.hinge) then
        bullet3d.constraint.destroy(self.hinge)
    end
end

bullet3d.constraint.create_hinge2()

bullet3d.constraint.create_hinge2(body_a,body_b,params)

Both bodies are required. The params table requires a world-space anchor and non-zero, orthogonal axis1 and axis2 vectors. Its initial linear suspension travel is one Defold unit in either direction. It optionally accepts collide_connected. The world is derived from body_a.

PARAMETERS

body_a btRigidBody
first body
body_b btRigidBody
second body
params table
anchor, axes, and options

RETURNS

constraint btTypedConstraint
hinge2 constraint

bullet3d.constraint.create_point_to_point()

bullet3d.constraint.create_point_to_point(body_a,body_b,params)

params.pivot_a is required. params.pivot_b is required with body_b; for a one-body constraint it is an optional world-space anchor. The params table also accepts collide_connected, which defaults to false. The world is derived from body_a; both bodies must belong to that same world.

PARAMETERS

body_a btRigidBody
first body
body_b btRigidBody
nil
second body or world
params table
pivots and options

RETURNS

constraint btTypedConstraint
point-to-point constraint

EXAMPLES

Join two bodies at matching local pivots and explicitly destroy the constraint when the script is finalized:
function init(self)
    local body_a = bullet3d.get_rigid_body("/body_a#collisionobject")
    local body_b = bullet3d.get_rigid_body("/body_b#collisionobject")
    self.constraint = bullet3d.constraint.create_point_to_point(body_a, body_b, {
        pivot_a = vmath.vector3(0.5, 0, 0),
        pivot_b = vmath.vector3(-0.5, 0, 0),
    })
end

function final(self)
    if self.constraint and bullet3d.constraint.is_valid(self.constraint) then
        bullet3d.constraint.destroy(self.constraint)
    end
end

bullet3d.constraint.create_slider()

bullet3d.constraint.create_slider(body_a,body_b,params)

The params table requires local frame A and, for a two-body constraint, local frame B. It optionally accepts use_linear_reference_frame_a and collide_connected. The world is derived from body_a.

PARAMETERS

body_a btRigidBody
first body
body_b btRigidBody
nil
second body or world
params table
local frames and options

RETURNS

constraint btTypedConstraint
slider constraint

bullet3d.constraint.create_universal()

bullet3d.constraint.create_universal(body_a,body_b,params)

Both bodies are required. The params table requires a world-space anchor and non-zero, orthogonal axis1 and axis2 vectors. It optionally accepts collide_connected. The world is derived from body_a.

PARAMETERS

body_a btRigidBody
first body
body_b btRigidBody
second body
params table
anchor, axes, and options

RETURNS

constraint btTypedConstraint
universal constraint

bullet3d.constraint.destroy()

bullet3d.constraint.destroy(constraint)

Destroy a constraint

PARAMETERS

constraint btTypedConstraint
constraint

bullet3d.constraint.enable_cone_twist_motor()

bullet3d.constraint.enable_cone_twist_motor(constraint,enabled)

Enable or disable the cone-twist motor

PARAMETERS

constraint btTypedConstraint
cone-twist constraint
enabled boolean
motor state

bullet3d.constraint.enable_spring()

bullet3d.constraint.enable_spring(constraint,axis,enabled)

Enable or disable a spring axis

PARAMETERS

constraint btTypedConstraint
spring 6-DOF or hinge2 constraint
axis number
one-based axis from 1 to 6
enabled boolean
spring state

bullet3d.constraint.get_6dof_angle()

bullet3d.constraint.get_6dof_angle(constraint,axis)

Get a current 6-DOF angle

PARAMETERS

constraint btTypedConstraint
6-DOF-derived constraint
axis number
one-based angular-axis index from 1 to 3

RETURNS

angle number
current angle in radians

bullet3d.constraint.get_6dof_axis()

bullet3d.constraint.get_6dof_axis(constraint,axis)

Get a current 6-DOF angular axis

PARAMETERS

constraint btTypedConstraint
6-DOF-derived constraint
axis number
one-based angular-axis index from 1 to 3

RETURNS

direction vector3
world-space unit axis

bullet3d.constraint.get_6dof_motor()

bullet3d.constraint.get_6dof_motor(constraint,axis)

Axes 1-3 are linear and axes 4-6 are angular. Bounce is zero for linear motors because Bullet only implements it for angular motors.

PARAMETERS

constraint btTypedConstraint
6-DOF-derived constraint
axis number
one-based axis from 1 to 6

RETURNS

enabled boolean
motor state
target_velocity number
target velocity
max_impulse number
maximum motor impulse
bounce number
angular bounce from 0 to 1

bullet3d.constraint.get_6dof_position()

bullet3d.constraint.get_6dof_position(constraint,axis)

Get a current 6-DOF linear position

PARAMETERS

constraint btTypedConstraint
6-DOF-derived constraint
axis number
one-based linear-axis index from 1 to 3

RETURNS

position number
relative position in Defold units

bullet3d.constraint.get_anchors()

bullet3d.constraint.get_anchors(constraint)

Get universal or hinge2 anchors

PARAMETERS

constraint btTypedConstraint
universal or hinge2 constraint

RETURNS

anchor_a vector3
world-space anchor on body A
anchor_b vector3
world-space anchor on body B

bullet3d.constraint.get_angles()

bullet3d.constraint.get_angles(constraint)

Get universal or hinge2 angles

PARAMETERS

constraint btTypedConstraint
universal or hinge2 constraint

RETURNS

angle_1 number
first angle in radians
angle_2 number
second angle in radians

bullet3d.constraint.get_axes()

bullet3d.constraint.get_axes(constraint)

Get universal or hinge2 axes

PARAMETERS

constraint btTypedConstraint
universal or hinge2 constraint

RETURNS

axis_1 vector3
first world-space unit axis
axis_2 vector3
second world-space unit axis

bullet3d.constraint.get_body_a()

bullet3d.constraint.get_body_a(constraint)

Get the first linked body

PARAMETERS

constraint btTypedConstraint
constraint

RETURNS

body btRigidBody
first body

bullet3d.constraint.get_body_b()

bullet3d.constraint.get_body_b(constraint)

Get the second linked body

PARAMETERS

constraint btTypedConstraint
constraint

RETURNS

body btRigidBody
nil
second body, or nil for a world constraint

bullet3d.constraint.get_collide_connected()

bullet3d.constraint.get_collide_connected(constraint)

Get whether connected bodies can collide

PARAMETERS

constraint btTypedConstraint
constraint

RETURNS

collide boolean
whether connected bodies can collide

bullet3d.constraint.get_cone_twist_limits()

bullet3d.constraint.get_cone_twist_limits(constraint)

Get cone-twist angular spans

PARAMETERS

constraint btTypedConstraint
cone-twist constraint

RETURNS

swing_span_1 number
first swing span in radians
swing_span_2 number
second swing span in radians
twist_span number
twist span in radians

bullet3d.constraint.get_frame_a()

bullet3d.constraint.get_frame_a(constraint)

Returns position and rotation. For one-body generic 6-DOF and slider constraints this is the user-body frame, despite Bullet storing it as its native frame B.

PARAMETERS

constraint btTypedConstraint
framed constraint

RETURNS

position vector3
local position
rotation quaternion
local rotation

bullet3d.constraint.get_frame_b()

bullet3d.constraint.get_frame_b(constraint)

Get local frame B

PARAMETERS

constraint btTypedConstraint
framed constraint

RETURNS

position vector3
local position or world frame position
rotation quaternion
local rotation or world frame rotation

bullet3d.constraint.get_hinge_angle()

bullet3d.constraint.get_hinge_angle(constraint)

Get the current hinge angle

PARAMETERS

constraint btTypedConstraint
hinge constraint

RETURNS

angle number
angle in radians

bullet3d.constraint.get_hinge_limits()

bullet3d.constraint.get_hinge_limits(constraint)

Get hinge angular limits

PARAMETERS

constraint btTypedConstraint
hinge constraint

RETURNS

lower number
lower angle in radians
upper number
upper angle in radians

bullet3d.constraint.get_hinge_motor()

bullet3d.constraint.get_hinge_motor(constraint)

Get hinge motor settings

PARAMETERS

constraint btTypedConstraint
hinge constraint

RETURNS

enabled boolean
motor state
target_velocity number
angular target velocity
max_impulse number
maximum angular motor impulse

bullet3d.constraint.get_limit()

bullet3d.constraint.get_limit(constraint,axis)

Axes 1-3 return linear limits in Defold units. Axes 4-6 return angular limits in radians.

PARAMETERS

constraint btTypedConstraint
6-DOF-derived constraint
axis number
one-based axis from 1 to 6

RETURNS

lower number
lower limit
upper number
upper limit

bullet3d.constraint.get_pivots()

bullet3d.constraint.get_pivots(constraint)

Get point-to-point pivots

PARAMETERS

constraint btTypedConstraint
point-to-point constraint

RETURNS

pivot_a vector3
local body-A pivot
pivot_b vector3
local body-B pivot or world anchor

bullet3d.constraint.get_slider_limits()

bullet3d.constraint.get_slider_limits(constraint)

Get slider limits

PARAMETERS

constraint btTypedConstraint
slider constraint

RETURNS

lower_linear number
lower linear limit in Defold units
upper_linear number
upper linear limit in Defold units
lower_angular number
lower angular limit in radians
upper_angular number
upper angular limit in radians

bullet3d.constraint.get_slider_motor()

bullet3d.constraint.get_slider_motor(constraint,motor)

Get slider motor settings

PARAMETERS

constraint btTypedConstraint
slider constraint
motor string
linear or angular

RETURNS

enabled boolean
motor state
target_velocity number
target velocity
max_force number
maximum motor force

bullet3d.constraint.get_slider_position()

bullet3d.constraint.get_slider_position(constraint)

Get the current slider position

PARAMETERS

constraint btTypedConstraint
slider constraint

RETURNS

position number
current linear position in Defold units

bullet3d.constraint.get_twist_angle()

bullet3d.constraint.get_twist_angle(constraint)

Get the current cone-twist twist angle

PARAMETERS

constraint btTypedConstraint
cone-twist constraint

RETURNS

angle number
twist angle in radians

bullet3d.constraint.get_type()

bullet3d.constraint.get_type(constraint)

Get the constraint type

PARAMETERS

constraint btTypedConstraint
constraint

RETURNS

type number
one of the bullet3d.constraint.CONSTRAINT_TYPE_* constants

bullet3d.constraint.get_type_name()

bullet3d.constraint.get_type_name(constraint)

Returns a stable lowercase diagnostic name such as "hinge" or "generic_6dof_spring".

PARAMETERS

constraint btTypedConstraint
constraint

RETURNS

name string
constraint type name

bullet3d.constraint.get_use_linear_reference_frame_a()

bullet3d.constraint.get_use_linear_reference_frame_a(constraint)

Get the slider linear reference-frame choice

PARAMETERS

constraint btTypedConstraint
slider constraint

RETURNS

use_frame_a boolean
true when linear calculations reference frame A

bullet3d.constraint.get_world()

bullet3d.constraint.get_world(constraint)

Get the owning world

PARAMETERS

constraint btTypedConstraint
constraint

RETURNS

world btDiscreteDynamicsWorld
owning world

bullet3d.constraint.is_active()

bullet3d.constraint.is_active(constraint)

Test whether a constraint is active in its world

PARAMETERS

constraint btTypedConstraint
constraint

RETURNS

active boolean
false while a linked body is disabled

bullet3d.constraint.is_angular_only()

bullet3d.constraint.is_angular_only(constraint)

Test angular-only mode

PARAMETERS

constraint btTypedConstraint
hinge or cone-twist constraint

RETURNS

angular_only boolean
angular-only state

bullet3d.constraint.is_limited()

bullet3d.constraint.is_limited(constraint,axis)

Test whether a 6-DOF axis is limited

PARAMETERS

constraint btTypedConstraint
6-DOF-derived constraint
axis number
one-based axis from 1 to 6

RETURNS

limited boolean
limit state

bullet3d.constraint.is_past_swing_limit()

bullet3d.constraint.is_past_swing_limit(constraint)

Test whether a cone-twist is past its swing limit

PARAMETERS

constraint btTypedConstraint
cone-twist constraint

RETURNS

past_limit boolean
swing-limit state

bullet3d.constraint.is_valid()

bullet3d.constraint.is_valid(constraint)

Test whether a constraint handle is valid

PARAMETERS

constraint btTypedConstraint
constraint handle

RETURNS

valid boolean
true while the native constraint exists

bullet3d.constraint.set_6dof_motor()

bullet3d.constraint.set_6dof_motor(constraint,axis,enabled,target_velocity,max_impulse,bounce)

Set 6-DOF motor settings

PARAMETERS

constraint btTypedConstraint
6-DOF-derived constraint
axis number
one-based axis from 1 to 6
enabled boolean
motor state
target_velocity number
target velocity
max_impulse number
non-negative maximum motor impulse
bounce number
nil
optional angular bounce from 0 to 1

bullet3d.constraint.set_angular_only()

bullet3d.constraint.set_angular_only(constraint,angular_only)

Set angular-only mode

PARAMETERS

constraint btTypedConstraint
hinge or cone-twist constraint
angular_only boolean
angular-only state

bullet3d.constraint.set_cone_twist_limits()

bullet3d.constraint.set_cone_twist_limits(constraint,swing_span_1,swing_span_2,twist_span,softness,bias,relaxation)

Set cone-twist angular spans

PARAMETERS

constraint btTypedConstraint
cone-twist constraint
swing_span_1 number
non-negative first swing span
swing_span_2 number
non-negative second swing span
twist_span number
non-negative twist span
softness number
nil
optional softness from 0 to 1
bias number
nil
optional bias from 0 to 1
relaxation number
nil
optional relaxation from 0 to 1

bullet3d.constraint.set_cone_twist_motor_target()

bullet3d.constraint.set_cone_twist_motor_target(constraint,target,constraint_space)

Set the cone-twist motor target

PARAMETERS

constraint btTypedConstraint
cone-twist constraint
target quaternion
target orientation
constraint_space boolean
nil
target is already in constraint space

bullet3d.constraint.set_frame_a()

bullet3d.constraint.set_frame_a(constraint,position,rotation)

Set local frame A

PARAMETERS

constraint btTypedConstraint
mutable framed constraint
position vector3
local position
rotation quaternion
local rotation

bullet3d.constraint.set_frame_b()

bullet3d.constraint.set_frame_b(constraint,position,rotation)

Set local frame B

PARAMETERS

constraint btTypedConstraint
mutable framed constraint
position vector3
local position or world frame position
rotation quaternion
local rotation or world frame rotation

bullet3d.constraint.set_hinge_axis()

bullet3d.constraint.set_hinge_axis(constraint,axis)

This function only supports hinges attached to the world. For a two-body hinge, change both local frames with set_frame_a and set_frame_b.

PARAMETERS

constraint btTypedConstraint
one-body hinge constraint
axis vector3
non-zero axis in body-A space

bullet3d.constraint.set_hinge_limits()

bullet3d.constraint.set_hinge_limits(constraint,lower,upper,bias,relaxation)

Set hinge angular limits

PARAMETERS

constraint btTypedConstraint
hinge constraint
lower number
lower angle in radians
upper number
upper angle in radians
bias number
nil
optional limit bias from 0 to 1
relaxation number
nil
optional relaxation from 0 to 1

bullet3d.constraint.set_hinge_motor()

bullet3d.constraint.set_hinge_motor(constraint,enabled,target_velocity,max_impulse)

Set hinge motor settings

PARAMETERS

constraint btTypedConstraint
hinge constraint
enabled boolean
motor state
target_velocity number
angular target velocity
max_impulse number
non-negative maximum angular motor impulse

bullet3d.constraint.set_hinge_motor_target()

bullet3d.constraint.set_hinge_motor_target(constraint,target_angle,time_step)

Set a hinge motor angle target

PARAMETERS

constraint btTypedConstraint
hinge constraint
target_angle number
target angle in radians
time_step number
positive step duration in seconds

bullet3d.constraint.set_limit()

bullet3d.constraint.set_limit(constraint,axis,lower,upper)

Set a 6-DOF axis limit

PARAMETERS

constraint btTypedConstraint
6-DOF-derived constraint
axis number
one-based axis from 1 to 6
lower number
lower limit
upper number
upper limit

bullet3d.constraint.set_pivots()

bullet3d.constraint.set_pivots(constraint,pivot_a,pivot_b)

Set point-to-point pivots

PARAMETERS

constraint btTypedConstraint
point-to-point constraint
pivot_a vector3
local body-A pivot
pivot_b vector3
local body-B pivot or world anchor

bullet3d.constraint.set_slider_limits()

bullet3d.constraint.set_slider_limits(constraint,lower_linear,upper_linear,lower_angular,upper_angular)

Set slider limits

PARAMETERS

constraint btTypedConstraint
slider constraint
lower_linear number
lower linear limit in Defold units
upper_linear number
upper linear limit in Defold units
lower_angular number
lower angular limit in radians
upper_angular number
upper angular limit in radians

bullet3d.constraint.set_slider_motor()

bullet3d.constraint.set_slider_motor(constraint,motor,enabled,target_velocity,max_force)

Set slider motor settings

PARAMETERS

constraint btTypedConstraint
slider constraint
motor string
linear or angular
enabled boolean
motor state
target_velocity number
target velocity
max_force number
non-negative maximum motor force

bullet3d.constraint.set_spring_damping()

bullet3d.constraint.set_spring_damping(constraint,axis,damping)

Set spring damping

PARAMETERS

constraint btTypedConstraint
spring 6-DOF or hinge2 constraint
axis number
one-based axis from 1 to 6
damping number
damping from 0 to 1

bullet3d.constraint.set_spring_equilibrium_point()

bullet3d.constraint.set_spring_equilibrium_point(constraint,axis,value)

With no axis, captures all current transforms. With an axis and no value, captures that axis. Linear values use Defold units and angular values use radians.

PARAMETERS

constraint btTypedConstraint
spring 6-DOF or hinge2 constraint
axis number
nil
optional one-based axis from 1 to 6
value number
nil
optional explicit equilibrium value

bullet3d.constraint.set_spring_stiffness()

bullet3d.constraint.set_spring_stiffness(constraint,axis,stiffness)

Stiffness is Bullet's solver tuning coefficient, not a force or torque value, and is therefore independent of physics.scale for every axis.

PARAMETERS

constraint btTypedConstraint
spring 6-DOF or hinge2 constraint
axis number
one-based axis from 1 to 6
stiffness number
non-negative stiffness

Constants

bullet3d.constraint.CONSTRAINT_TYPE_CONE_TWIST

Cone-twist constraint type


bullet3d.constraint.CONSTRAINT_TYPE_GENERIC_6DOF

Generic 6-DOF constraint type


bullet3d.constraint.CONSTRAINT_TYPE_GENERIC_6DOF_SPRING

Generic spring 6-DOF constraint type


bullet3d.constraint.CONSTRAINT_TYPE_HINGE

Hinge constraint type


bullet3d.constraint.CONSTRAINT_TYPE_HINGE2

Hinge2 constraint type


bullet3d.constraint.CONSTRAINT_TYPE_POINT_TO_POINT

Point-to-point constraint type


bullet3d.constraint.CONSTRAINT_TYPE_SLIDER

Slider constraint type


bullet3d.constraint.CONSTRAINT_TYPE_UNIVERSAL

Universal constraint type