Manual
Manual
Joints
A joint holds two bodies together: a door on its hinge, a drawer on its runners, a wheel on a car, a rope, a spring, a weld. This page covers what every joint shares, each of the six joints, placing their anchors in the Scene view, and joints that break.
How a joint holds two bodies
A joint is a component on one of the two bodies. It holds:
- the body it is on: the nearest Rigidbody 2D at or above its entity. Added in the editor where there is none, the joint brings a Rigidbody 2D to its entity.
- its Connected Body: another entity with a Rigidbody 2D, or one under it, dragged from the Hierarchy into the slot. Left empty, the joint holds its own body to a point in the world.
Every joint has these fields:
| Field | What it does |
|---|---|
| Connected Body | The other body it holds; none for a point in the world. |
| Enable Collision | Whether the two bodies still collide with each other. Off to begin with. |
| Auto Configure Connected Anchor | Makes the connected anchor where the anchor is, as the joint is made, and then shows where that was. On to begin with, except on the Distance and Spring joints. |
| Anchor | Where it holds its own body, in its entity's own units. |
| Connected Anchor | Where it holds the other body, in that entity's own units, or in the world's where there is no Connected Body. |
| Break Force | The force it breaks at, in newtons. Infinity, never, to begin with. |
| Break Torque | The torque it breaks at, in newton meters. Infinity to begin with. |
The joint is made as the game starts playing, or as it is added while it plays. Where it works a value out as it is made, such as the connected anchor, it writes the value into its fields, so you can see what it was made with.
While a joint's entity is picked, the Scene view draws it in light blue: a ring at each anchor, the line between them, and the way a slider or a wheel's suspension moves.
Hinge Joint 2D
Two bodies turning about one point, as a door on its hinge or a wheel on its axle.
| Field | What it does |
|---|---|
| Use Motor | The motor turns it. |
| Motor Speed | How fast the motor turns this body against the other, in degrees a second, anticlockwise. |
| Max Motor Torque | The most torque the motor turns it with, in newton meters. |
| Use Limits | It stops turning past Lower Angle and Upper Angle. |
| Lower Angle, Upper Angle | The least and the most it turns, in degrees from where it was as it was made, each within 178 either way. They start at 0 and 90. |
Slider Joint 2D
Two bodies sliding along a line, as a drawer or a lift, kept at the angle they were at.
| Field | What it does |
|---|---|
| Angle | Which way it slides, in degrees anticlockwise from the world's X as it is made. The line goes through Anchor, and turns with the connected body afterward. |
| Use Motor | The motor drives it along. |
| Motor Speed | How fast the motor drives it, in meters a second. |
| Max Motor Force | The most force the motor drives it with, in newtons. |
| Use Limits | It stops sliding past Lower Translation and Upper Translation. |
| Lower Translation, Upper Translation | The least and the most it slides, in meters from where it was made. They start at 0 and 1. |
Wheel Joint 2D
A wheel on a car. The joint goes on the car, and its Connected Body is the wheel, which turns freely about its Connected Anchor and is held to the car by a suspension, a spring along a line.
| Field | What it does |
|---|---|
| Suspension Damping Ratio | How quickly the suspension's bounce dies away: 0 never, 1 at once. 0.7 to begin with. |
| Suspension Frequency | How stiff the suspension is, in bounces a second. 2 to begin with. |
| Suspension Angle | Which way the suspension moves, in degrees from the world's X as it is made: 90, to begin with, is straight up. It turns with the car afterward. |
| Use Motor | The motor turns the wheel. |
| Motor Speed | How fast the motor turns the wheel against the car, in degrees a second, anticlockwise. |
| Max Motor Torque | The most torque the motor turns the wheel with, in newton meters. |
With no wheel, it holds the car to the world.
Distance Joint 2D
Two bodies kept a distance apart, as by a rod, or no further apart, as by a rope.
| Field | What it does |
|---|---|
| Auto Configure Distance | Makes the distance how far apart the anchors are as the joint is made, and then shows it. On to begin with. |
| Distance | How far apart the anchors are kept, in meters. |
| Max Distance Only | Lets the bodies come nearer, as on a rope, and keeps them no further apart than Distance. |
Spring Joint 2D
Two bodies pulled toward a distance apart by a spring.
| Field | What it does |
|---|---|
| Auto Configure Distance | Makes the distance how far apart the anchors are as the joint is made. On to begin with. |
| Distance | How far apart the spring pulls the anchors, in meters. |
| Damping Ratio | How quickly the spring's bounce dies away: 0 never, 1 at once. |
| Frequency | How stiff the spring is, in bounces a second. 0 is as stiff as a rod. 1 to begin with. |
Fixed Joint 2D
Two bodies held together as they were as it was made, as if welded.
| Field | What it does |
|---|---|
| Damping Ratio | How quickly its give dies away: 0 never, 1 at once. |
| Frequency | How stiffly it holds, in bounces a second. 0, to begin with, holds as stiff as there is; more lets it give like a spring. |
Edit Joint
Edit Joint, the button at the top of a joint's section, places its anchors in the Scene view. A dot on Anchor moves where the joint holds its own body. A second dot, on Connected Anchor, moves where it holds the other, shown only while Auto Configure Connected Anchor is off. Each drag is one Ctrl+Z. Escape, the button again, choosing a tool, or picking something else ends editing.
When a joint breaks
A joint breaks when it holds with more force than its Break Force, or more torque than its Break Torque, in a step. It is taken off its entity as the step ends, and reported in JointsBroken, which a system reads as it reads what touched (see Contacts and queries):
Physics2D physics = context.Services.Get<Physics2D>();foreach (JointBroken2D broke in physics.JointsBroken){ Log.Info($"{broke.Joint} joint on {broke.Entity} broke, holding {broke.Force} N and {broke.Torque} N·m"); // broke.ConnectedBody is the other body it held, or 0 for a point in the world}In the Scripting API
- HingeJoint2D, SliderJoint2D, WheelJoint2D, DistanceJoint2D, SpringJoint2D and FixedJoint2D: the joints.
- JointBroken2D and Joint2DKind: a joint that broke, and which kind it was.
- EntityRef: the Connected Body slot.
