DistanceJoint2D
Optional feature
DistanceJoint2D is part of 2D Physics. A build includes it only when a scene, prefab or script uses it — see Feature cropping.
From a script
ts
import { DistanceJoint2DComponent } from "mmpx";
const distanceJoint2D = this.entity.TryGetComponent(DistanceJoint2DComponent);Full API: DistanceJoint2DComponent.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
Connected BodyconnectedBody | Rigidbody2D | — | The other Rigidbody2D — empty ties it to the world |
Enable CollisionenableCollision | boolean | false | Whether the two connected bodies still collide with each other |
Anchor XanchorX | number | 0 | |
Anchor YanchorY | number | 0 | |
Auto Connected AnchorautoConfigureConnectedAnchor | boolean | true | Puts the connected anchor where this anchor is when the joint is created |
Connected Anchor XconnectedAnchorX | number | 0 | |
Connected Anchor YconnectedAnchorY | number | 0 | |
Auto DistanceautoConfigureDistance | boolean | true | The distance between the anchors when the joint is created |
Distancedistance | number (0 … ∞) (px) | 100 | |
Max Distance OnlymaxDistanceOnly | boolean | false | A rope: the anchors can come closer, never further apart |
Breaking
| Field | Type | Default | Description |
|---|---|---|---|
Break ForcebreakForce | number (0 … ∞) | 0 | Breaks when pulled harder than this (kg·px/s²) — 0 = never |
Break TorquebreakTorque | number (0 … ∞) | 0 | Breaks when twisted harder than this (kg·px²/s²) — 0 = never |