# Class: DistanceConstraint

## Phaser .Physics .P2. DistanceConstraint

Physics DistanceConstraint Constructor

#### new DistanceConstraint(world, bodyA, bodyB, distance, maxForce)

  A constraint that tries to keep the distance between two bodies constant.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `world` | Phaser.Physics.P2 |  | A reference to the P2 World.
  `bodyA` | p2.Body |  | First connected body.
  `bodyB` | p2.Body |  | Second connected body.
  `distance` | number |  | The distance to keep between the bodies.
  `maxForce` | number | <optional> | The maximum force that should be applied to constrain the bodies.

  Source:
    - physics/p2/DistanceConstraint.js, line 19

### Members

#### game

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | Local reference to game.

  Source:
    - physics/p2/DistanceConstraint.js, line 26

#### world

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `world` | Phaser.Physics.P2 | Local reference to P2 World.

  Source:
    - physics/p2/DistanceConstraint.js, line 31