# Distance Joint 2D

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

```
component physics.DistanceJoint2D
```

Keeps a distance between this body and the Target body. Length 0 uses the distance at start.

## From a script

Reel a rope in and out by changing the joint length.

```aes check
package player

import (
    "aego/input"
    "aego/math"
)

script Rope {
    var Reel float = 2

    func Update(dt float) {
        j := node.Get<DistanceJoint2D>()
        j.Length = math.Max(j.Length+input.Axis("Reel")*Reel*dt, 0.5)
        j.MaxLength = j.Length
    }
}
```

## Fields

| Name | Script name | Type | Default | Description |
|---|---|---|---|---|
| Target | `Target` | `NodeRef` | `none` | The other body; both nodes need a Rigid Body 2D. |
| Anchor A | `AnchorA` | `Vec2` | `(0, 0)` | Attachment point on this node, in node space. |
| Anchor B | `AnchorB` | `Vec2` | `(0, 0)` | Attachment point on the Target node, in its node space. |
| Length | `Length` | `float` | `0` | Rest length in units; 0 takes the distance between the anchors at start. |
| Min Length | `MinLength` | `float` | `0` | Shortest allowed length. With Min and Max both 0 the joint is a rigid rod, or a spring without a lower limit when Stiffness is set. |
| Max Length | `MaxLength` | `float` | `0` | Longest allowed length; a rope has Min 0 and Max at the rope length. |
| Stiffness | `Stiffness` | `float` | `0` | Spring stiffness in newtons per unit; 0 makes the length rigid within Min and Max. |
| Damping | `Damping` | `float` | `0` | Spring damping; 0 never damps, higher values stop the oscillation sooner. |
| Collide Connected | `CollideConnected` | `bool` | `false` | Lets the two connected bodies collide with each other. |
