Legacy Documentation: Version 5.2
Spring Joint 2D
Hinge Joint 2D

Distance Joint 2D

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
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961