Legacy Documentation: Version 4.6
Language: English
Spring Joint 2D
Hinge Joint 2D

Distance Joint 2D

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Scripting

The Distance Joint 2D component allows two Sprite objects controlled by rigidbody physics to be attached together to keep them a certain distance apart. Note that unlike the Spring Joint 2D, the Distance Joint applies a hard limit rather than a gradual force to restore the desired distance.

Property: Function:
Collide Connected Can the two connected objects collide with each other?
Connected Rigidbody The other Rigidbody2D object that the one with the joint is connected to. If this is null then the othen end of the joint will be fixed at a point in space.
Anchor Coordinate in local space where the end point of the joint is attached.
Connected Anchor Coordinate in the other object’s local space where its end of the joint is attached.
Distance The distance that the joint keeps between the two objects.
Max Distance Only If enabled, the joint will only enforce a maximum distance (ie, the objects can still move closer). If disabled, the distance between the objects will be fixed.

Details

Both objects connected by the joint must have a Rigidbody 2D component attached (or alternatively, the other end of the joint can be fixed in space by setting Connected Rigidbody to null). The ends of the joint can rotate relative to the objects but the distance between them will be kept constant.

Spring Joint 2D
Hinge Joint 2D