Box2D. 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

  • Box2dJoint

Methods

getFrequency() → {number}

Gets the joint frequency in Hertz

Returns:
Type: 
number

getMaxForce() → {number}

Gets the maximum force in Newtons

Returns:
Type: 
number

getTarget() → {Vector2}

Get the target point in world coordinates

Returns:
Type: 
Vector2

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