To connect two 2D Physics Core objects, add a Physics Constraint component to one of them, and assign the other as the object it connects to.
Note: This documentation is about using Pose, Area, and Constraint components. To use 2D physics in the Unity Editor using components like the Rigidbody 2D component, refer to 2D physics instead.
Follow these steps:
Select a GameObject with a Physics Pose component.
In the Inspector window, select Add Component.
Select Physics 2D (Core), then select a constraint component, for example Physics Constraint Distance.
Unity connects one end of the constraint to this GameObject, by setting Pose A Source to the Physics Pose component. To connect a different GameObject instead, set Pose A Source to Custom.
Expand the Pose section, then drag the second GameObject you want to connect to the Pose B Target property, or select the picker (⊙).
For the full list of Physics Constraint components and what each one does, refer to Introduction to constraints.
Note: Some constraints don’t have a spring.
To make the constraint act like a spring, follow these steps:
Note: Some constraints don’t have a motor.
To make the constraint act like a winch that pulls or pushes the connected objects, follow these steps:
To share the same properties across multiple constraints, create a definition asset. For more information, refer to Share properties across multiple 2D Physics Core components.
To also allow the shapes on the two connected objects to collide with each other, enable Collide Connected in the Definition section of the constraint component.