2D Joints
Fixed Joint 2D

Distance Joint 2D

Switch to Scripting

Distance Joint 2D attaches two game objects controlled by rigidbody physics together and keeps them a certain distance apart.

Property: Function:
Enable Collision Can the two connected objects collide with each other? Check the box for yes.
Connected Rigid Body Specify here the other object this joint connects to. Leave this as None and the other end of the joint will be fixed at a point in space defined by the Connected Anchor setting. Select the circle to the right of the field to view a list of objects to connect to.
Auto Configure Connected Anchor Check this box to automatically set the anchor location for the other object this joint connects to. (Check this instead of completing the Connected Anchor fields.)
Anchor The place (in terms of X, Y co-ordinates on the RigidBody) where the end point of the joint connects to this object.
Connected Anchor The place (in terms of X, Y co-ordinates on the RigidBody) where the end point of the joint connects to the other object.
Auto Configure Distance Check this box to automticaly detect the distance between the two objects and set it as a distance that the joint keeps between the two objects. (Check this instead of completing the Distance field.)
Distance Specify the distance that the joint keeps between the two objects.
Max Distance Only If enabled, the joint only enforces a maximum distance (ie, the objects can still move closer). If disabled, the distance between the objects is fixed.
Break Force Specify the force level needed to break and so delete the joint. Infinity means it is unbreakable.

Details

(See also Joints 2D: Details and Hints for useful background information on all 2D joints.)

The aim of this joint is to keep distance between two points. Those two points can be two Rigidbody2D components or a Rigidbody2D component and a fixed position in the world. (Connect to a fixed position in the world by setting Connected Rigidbody to None).

The joint does not apply torque. It does apply a linear force to both connected items, using a very stiff, simulated spring to maintain the distance. (You cannot configure the spring).

This joint has an either-or selectable constraint. It’s either one of the other, ([A] OR [B] listed here):

  • Constraint [A]: Maintains a fixed distance between two anchor points on two bodies (when Max Distance Only is UNchecked).

OR

  • Constraint [B]: Maintains maximum distance only between two anchor points on two bodies (when Max Distance Only is checked).

For Example:

You can use this joint to construct physical objects that need to react as if they are connected together with a rigid connection that can rotate.

  • Using Contraint [A] (Max Distance Only UNchecked), you have a fixed length connection, such as two wheels on a bicycle.

  • Using Contraint [B] (Max Distance Only checked), you have a constrained length connection. Using the bicycle example, its wheels can move closer together but never further apart than the distance you specify; a comedy clown’s bicycle!

2D Joints
Fixed Joint 2D