Class PrismaticConstraint

Constraint that only allows bodies to move along a line, relative to each other.

Also called "slider constraint".



Ability to create using only a point and a worldAxis


var constraint = new PrismaticConstraint(bodyA, bodyB, {
localAxisA: [0, 1]




bodyA: Body

First body participating in the constraint.

bodyB: Body

Second body participating in the constraint.

collideConnected: boolean

Set to true if you want the connected bodies to collide.


equations: Equation[]

Equations to be solved in this constraint

localAnchorA: Vec2
localAnchorB: Vec2
localAxisA: Vec2
lowerLimit: number

Lower constraint limit. The constraint position is forced to be larger than this value.

lowerLimitEnabled: boolean

Set to true to enable lower limit.

lowerLimitEquation: ContactEquation
maxForce: number

Max force for the motor

motorEnabled: boolean

The current motor state. Enable or disable the motor using .enableMotor

motorEquation: Equation

Equation used for the motor.

motorSpeed: number

Set the target speed for the motor.

position: number

The position of anchor A relative to anchor B, along the constraint axis.

type: 2 | 1 | -1 | 3 | 4 | 5

The type of constraint. May be one of Constraint.DISTANCE, Constraint.GEAR, Constraint.LOCK, Constraint.PRISMATIC or Constraint.REVOLUTE.

upperLimit: number

Upper constraint limit. The constraint position is forced to be smaller than this value.

upperLimitEnabled: boolean

Set to true to enable upper limit.

upperLimitEquation: ContactEquation
DISTANCE: 1 = ...
GEAR: 2 = ...
LOCK: 3 = ...
OTHER: -1 = ...
PRISMATIC: 4 = ...
REVOLUTE: 5 = ...


  • Disable the rotational motor

    Returns void

  • Enable the motor

    Returns void

  • Set the constraint limits.


    • lower: number

      lower limit

    • upper: number

      upper limit

    Returns void

  • Set max bias for this constraint.


    • maxBias: number

    Returns void

  • Set relaxation for this constraint.


    • relaxation: number

    Returns void

  • Set stiffness for this constraint.


    • stiffness: number

    Returns void

  • Update the constraint equations. Should be done if any of the bodies changed position, before solving.

    Returns void