Box2dTargetJoint

Box2D Target Joint, also known as a mouse joint

  • Used to make a point on a object track a specific world point target
  • This a soft constraint with a max force
  • This allows the constraint to stretch and without applying huge forces

Constructor

new Box2dTargetJoint(object, fixedObject, worldPos)

Create a target joint

Parameters:
NameTypeDescription
objectBox2dObject
fixedObjectBox2dObject
worldPosVector2

Extends

Methods

destroy()

Destroy this joint

getAnchorA() → {Vector2}

Get the first anchor for this joint in world coordinates

Returns:
Type: 
Vector2

getAnchorB() → {Vector2}

Get the second anchor for this joint in world coordinates

Returns:
Type: 
Vector2

getCollideConnected() → {boolean}

Check if the connected bodies should collide

Returns:
Type: 
boolean

getFrequency() → {number}

Gets the joint frequency in Hertz

Returns:
Type: 
number

getMaxForce() → {number}

Gets the maximum force in Newtons

Returns:
Type: 
number

getObjectA() → {Box2dObject}

Get the first object attached to this joint

Returns:
Type: 
Box2dObject

getObjectB() → {Box2dObject}

Get the second object attached to this joint

Returns:
Type: 
Box2dObject

getReactionForce(time) → {Vector2}

Get the reaction force on bodyB at the joint anchor given a time step

Parameters:
NameTypeDescription
timenumber
Returns:
Type: 
Vector2

getReactionTorque(time) → {number}

Get the reaction torque on bodyB in N*m given a time step

Parameters:
NameTypeDescription
timenumber
Returns:
Type: 
number

getTarget() → {Vector2}

Get the target point in world coordinates

Returns:
Type: 
Vector2

isActive() → {boolean}

Check if either connected body is active

Returns:
Type: 
boolean

setFrequency(hz)

Sets the joint frequency in Hertz

Parameters:
NameTypeDescription
hznumber

setMaxForce(force)

Sets the maximum force in Newtons

Parameters:
NameTypeDescription
forcenumber

setTarget(pos)

Set the target point in world coordinates

Parameters:
NameTypeDescription
posVector2