# PhysicsDistanceJoint

> Connects an anchor point on body A with an anchor point on body B via a line segment of a specified distance.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.U2D.Physics](/engine/6000.7/script-reference/unity/u2d/physics.md)
* **Assembly:** UnityEngine.PhysicsCore2DModule
* **Implements:** [IEquatable\<PhysicsDistanceJoint>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public readonly struct PhysicsDistanceJoint : IEquatable<PhysicsDistanceJoint>
```

## Constructors

| Constructor                                                                                                                             | Description                           |
| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- |
| [PhysicsDistanceJoint(Unity.U2D.Physics.PhysicsHandle)](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/ctor.md) | Create a joint from a physics handle. |

## Properties

| Property                                                                                                                                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [bodyA](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/bodya.md)                                                 | The first body the joint constrains.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [bodyB](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/bodyb.md)                                                 | The second body the joint constrains.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [callbackTarget](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/callbacktarget.md)                               | Get/Set the [Object](/engine/6000.7/script-reference/unityengine/object.md) that event callbacks for this joint will be sent to. Care should be taken with any [Object](/engine/6000.7/script-reference/unityengine/object.md) assigned as a callback target that isn't a [Object](/engine/6000.7/script-reference/unityengine/object.md) as this assignment will not in itself keep the object alive and can be garbage collected. To avoid this, you should have at least a single reference to the object in your code. To remove the object assigned here, set the callback target to NULL. |
| [collideConnected](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/collideconnected.md)                           | Whether the shapes on the pair of bodies can come into contact.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [currentAngularSeparationError](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/currentangularseparationerror.md) | Get the current angular separation error for this joint, in degrees. This does not consider admissible movement.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [currentConstraintForce](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/currentconstraintforce.md)               | Get the current constraint force used by the joint, usually in newtons.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [currentConstraintTorque](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/currentconstrainttorque.md)             | Get the current constraint torque used by the joint, usually in newton-meters.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [currentDistance](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/currentdistance.md)                             | Get the current distance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [currentLinearSeparationError](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/currentlinearseparationerror.md)   | Get the current linear separation error for this joint, usually in meters. This does not consider admissible movement.                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [currentMotorForce](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/currentmotorforce.md)                         | The current motor force, usually in newtons.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [definition](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/definition.md)                                       | Get or set the joint definition. Reading returns the joint's current configuration, including [\_bodyA](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/bodya.md) and [\_bodyB](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/bodyb.md). Writing applies every configurable property in place but does not change the connected bodies, which are fixed when the joint is created.                                                                                                                                                              |
| [distance](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/distance.md)                                           | The desired distance constraint i.e. the rest length of this joint. This has a lower stable limit of just above zero.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [drawScale](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/drawscale.md)                                         | Controls the scaling of the joint drawing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [drawTarget](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/drawtarget.md)                                       | Controls which Unity editor views this joint is drawn into.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| [enableLimit](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/enablelimit.md)                                     | Enable/Disable the joint distance limit.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [enableMotor](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/enablemotor.md)                                     | Enable/Disable the joint motor.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [enableSpring](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/enablespring.md)                                   | Enable/Disable the spring behaviour. If false then the joint will be rigid, overriding the limit and motor.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| [forceThreshold](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/forcethreshold.md)                               | The force threshold beyond which a joint event will be produced.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [isOwned](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/isowned.md)                                             | Get if the joint is owned. See [PhysicsJoint.SetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsjoint/setowner.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [isValid](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/isvalid.md)                                             | Checks if the joint is valid.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [jointType](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/jointtype.md)                                         | Gets the joint type. See [PhysicsJoint.JointType](/engine/6000.7/script-reference/unity/u2d/physics/physicsjoint/jointtype.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [localAnchorA](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/localanchora.md)                                   | The local anchor frame constraint relative to bodyA's origin.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [localAnchorB](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/localanchorb.md)                                   | The local anchor frame constraint relative to bodyB's origin.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [maxDistanceLimit](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/maxdistancelimit.md)                           | Maximum distance limit of this joint.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [maxMotorForce](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/maxmotorforce.md)                                 | The maximum force the motor can apply, usually in newtons.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [minDistanceLimit](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/mindistancelimit.md)                           | Minimum distance limit of this joint. This will be clamped to a lower stable limit.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [motorSpeed](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/motorspeed.md)                                       | The desired motor speed, usually in meters per second.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [owner](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/owner.md)                                                 | The owner object associated with this joint, or NULL if no owner has been specified. This is a convenience property that returns the same value as [PhysicsDistanceJoint.GetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/getowner.md).                                                                                                                                                                                                                                                                                                                         |
| [ownerUserData](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/owneruserdata.md)                                 | Get [PhysicsUserData](/engine/6000.7/script-reference/unity/u2d/physics/physicsuserdata.md) that can be used for any purpose, typically by the owner only.                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [physicsHandle](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/physicshandle.md)                                 | Get the physics handle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [selectedDrawing](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/selecteddrawing.md)                             | Controls whether this joint is drawn individually when the world is drawn.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [springDamping](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/springdamping.md)                                 | The spring linear damping, non-dimensional.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| [springFrequency](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/springfrequency.md)                             | The spring linear stiffness frequency, in cycles per second.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [springLowerForce](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/springlowerforce.md)                           | The lower spring force controls how much tension the spring can sustain.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [springUpperForce](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/springupperforce.md)                           | The upper spring force controls how much compression the spring can sustain.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [torqueThreshold](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/torquethreshold.md)                             | The torque threshold beyond which a joint event will be produced.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [tuningDamping](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/tuningdamping.md)                                 | Controls the joint stiffness damping, non-dimensional. Use 1 for critical damping.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [tuningFrequency](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/tuningfrequency.md)                             | Controls the joint stiffness frequency, in cycles per second.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [userData](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/userdata.md)                                           | Get/Set [PhysicsUserData](/engine/6000.7/script-reference/unity/u2d/physics/physicsuserdata.md) that can be used for any purpose. The physics system doesn't use this data, it is entirely for custom use.                                                                                                                                                                                                                                                                                                                                                                                      |
| [world](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/world.md)                                                 | Get the world the body is attached to.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [worldDrawing](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/worlddrawing.md)                                   | Controls whether this joint is automatically drawn when the world is drawn.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

## Methods

| Method                                                                                                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Destroy](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/destroy.md)                   | Destroy the joint. If the object is owned with [PhysicsJoint.SetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsjoint/setowner.md) then you must provide the owner key it returned. Failing to do so will return a warning and the joint will not be destroyed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [Draw](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/draw.md)                         | Draw this joint's current state once, as custom drawing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [GetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/getowner.md)                 | Get the owner object associated with this joint as specified using [PhysicsJoint.SetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsjoint/setowner.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [SetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/setowner.md)                 | Set the (optional) owner object associated with this joint and return an owner key that must be specified when destroying the joint with [PhysicsJoint.Destroy](/engine/6000.7/script-reference/unity/u2d/physics/physicsjoint/destroy.md). The physics system provides access to all objects, including the ability to destroy them so this feature can be used to stop accidental destruction of objects that are owned by other objects. You can only set the owner once, multiple attempts will produce a warning. The lifetime of the specified owner object is not linked to this joint i.e. this joint will still be owned by the owner object, even if it is destroyed. It is also valid to not specify an owner object (NULL) to simply gain an owner key however it can be useful, if simply for debugging purposes and discovery, to know which object is the owner. |
| [SetOwnerUserData](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/setowneruserdata.md) | Set [PhysicsUserData](/engine/6000.7/script-reference/unity/u2d/physics/physicsuserdata.md) that can be used for any purpose, typically by the owner only.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [WakeBodies](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/wakebodies.md)             | Wake the pair of bodies the joint is constraining.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

## Static Methods

| Method                                                                                                 | Description                                                                                                                                                                                                                             |
| ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Create](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/create.md)             | Create a [PhysicsDistanceJoint](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint.md) in the specified world.                                                                                                      |
| [DestroyBatch](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/destroybatch.md) | Destroy a batch of joints. Owned joints will produce a warning and will not be destroyed (see [PhysicsJoint.SetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsjoint/setowner.md)). Any invalid joints will be ignored. |

## Operators

| Operator                                                                                                      | Description                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [PhysicsJoint](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/op-implicit.md)         | Cast to the base [PhysicsJoint](/engine/6000.7/script-reference/unity/u2d/physics/physicsjoint.md).                                                                                                                                                                                                                                                                                        |
| [PhysicsDistanceJoint](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint/op-implicit.md) | Cast to a [PhysicsDistanceJoint](/engine/6000.7/script-reference/unity/u2d/physics/physicsdistancejoint.md) from the base [PhysicsJoint](/engine/6000.7/script-reference/unity/u2d/physics/physicsjoint.md). The provided joint must be a joint type of [PhysicsJoint.JointType.DistanceJoint](/engine/6000.7/script-reference/unity/u2d/physics/physicsjoint/jointtype/distancejoint.md). |
