Quick answer: DistanceJoint2D is a soft constraint that the Box2D solver may not perfectly enforce in a single step. Stretching shows up under heavy load or extreme mass ratios. Raise Physics2D → Velocity Iterations and Position Iterations, balance masses, and consider Max Distance Only for rope-like behavior.
Here is how to fix Unity DistanceJoint2D that visibly stretches past its configured distance under load. You set Distance to 2 meters, but a fast-swinging body shoots out to 3+ meters before snapping back. The joint is doing its job — just not strongly enough. The Box2D solver is iterative; with too few iterations or extreme mass ratios it cannot fully correct the constraint each step.
The Symptom
Two RigidBody2Ds connected by a DistanceJoint2D. Distance configured to 2.0. At rest the bodies stay at 2.0 m. Apply force or rotate quickly and the bodies briefly separate to 2.5–3.0 m before the joint pulls them back. On lower physics rates (Time.fixedDeltaTime > 0.02), the stretch is severe enough to look broken.
What Causes This
Solver iteration count. Box2D resolves constraints iteratively. The default 8 velocity / 3 position iterations are tuned for speed, not rigidity. Heavy-load joints need more iterations to converge.
Extreme mass ratio. If one body has mass 1000 and the other has mass 1, the solver struggles to keep both honoring the constraint. Reducing the ratio to 10:1 or less dramatically improves stability.
High relative velocity. Fast-moving bodies traverse more distance per substep than the joint can correct. Reducing fixed timestep increases solver fidelity.
Auto Configure Distance enabled while bodies move. If Auto Configure is on, the joint resets its distance to the current world distance whenever you change connected bodies. Disabling it locks the configured distance.
The Fix
Step 1: Raise solver iterations. Open Edit → Project Settings → Physics 2D. Set Velocity Iterations to 16 and Position Iterations to 8. These are the most effective levers for joint rigidity.
Step 2: Balance mass ratios.
// Aim for less than 10:1 mass ratio across joints
heavyBody.mass = 5f;
lightBody.mass = 1f;
If gameplay requires a 1000kg-anchor + 1kg-pickup connection, attach a hidden intermediate body of moderate mass and tie both ends to it via separate joints.
Step 3: Disable Auto Configure Distance. On the DistanceJoint2D, uncheck Auto Configure Distance. Set the Distance field to your desired length explicitly. Auto Configure resets the value any time the connected body changes, including assignment in Awake.
Step 4: Use Max Distance Only for ropes. A rope can compress (slack) but cannot stretch. Enable Max Distance Only and the joint behaves accordingly. Without it, the joint also resists compression, which feels like a rigid rod.
using UnityEngine;
public class RopeSetup : MonoBehaviour
{
[SerializeField] private Rigidbody2D anchor;
[SerializeField] private float length = 2f;
void Awake()
{
var joint = gameObject.AddComponent<DistanceJoint2D>();
joint.connectedBody = anchor;
joint.autoConfigureDistance = false;
joint.distance = length;
joint.maxDistanceOnly = true;
joint.enableCollision = false;
}
}
Step 5: Lower fixed timestep for fast motion. If your bodies regularly exceed 5 m/s, set Fixed Timestep to 0.01 (100 Hz physics). The cost is ~2x physics CPU, but stretching artifacts disappear at speed.
When DistanceJoint2D Is the Wrong Tool
For perfectly rigid two-body links (a hammer head bolted to a handle), use FixedJoint2D or parent the bodies. DistanceJoint2D’s soft constraint will always show some give under load. For chains, use a series of short DistanceJoint2Ds each constraining adjacent links rather than one long joint — iterative solvers handle many short constraints better than one long one.
Damping for Stability
If your joint oscillates rather than stretches, add damping via the Damping Ratio field. Values 0.3–0.7 settle the joint without making it feel sticky. Combined with Frequency 5–10 Hz, this models a slightly elastic constraint that absorbs sudden loads instead of letting them propagate.
“Box2D is iterative. More iterations cost CPU but buy rigidity. Mass ratios under 10:1 keep solver happy. Disable Auto Configure when scripting joints.”
Related Issues
For other 2D physics issues, see Rigidbody2D Shaking and Physics Jittery Movement.
More iterations. Balanced masses. Auto Configure off. The rope holds.