joint2d
Joins this node's body to connected_body. kind is fixed, hinge, slider, rope, spring, groove or generic; both ends need a body2d on or above the node.…
On this page
2d · physics · 13 properties · 2D
Joins this node's body to connected_body. kind is fixed, hinge, slider, rope, spring, groove or generic; both ends need a body2d on or above the node. axes limits and drives each free axis.
In a scene, joint2d is the node key that applies it. A script reaches each property below as a field on node.joint2d: reading one asks the running component, and assigning one leaves the rest alone. The whole table is node.joint2d.get() and node.joint2d.set(table).
Properties
| property | type | default | description |
|---|---|---|---|
anchor |
vec2 | [0,0] |
Where the joint attaches on this node, in its own space |
anchor_rotation |
float | 0 |
Turns this end's joint frame: what a hinge's angle and its limits measure from, and the relative turn a fixed joint holds. Radians in the file |
axes |
list | [] |
One record per free axis to limit or drive. A rope's x takes no limits (max_length is its limit); a spring's x is its spring, whose motor stays off |
axis |
vec2 | [1,0] |
The joint frame's x axis: what a slider or a groove slides along, and a generic joint's x names |
collide_connected |
bool | false |
Let the two joined bodies collide with each other |
connected_anchor |
vec2 | [0,0] |
Where it attaches on the other node, in that node's space |
connected_anchor_rotation |
float | 0 |
The same for the other end's frame |
connected_axis |
vec2 | [0,0] |
The same axis in the other node's space, for a slider, a groove or a generic joint; zero takes axis |
connected_body |
node | — | The node at the joint's other end; this node is the first end |
enabled |
bool | true |
Hold the two bodies together at all. Off keeps the joint and stops solving it; an articulation leaves its chain instead, as rapier's chains ignore the switch |
kind |
enum | fixed |
How the two bodies may move relative to each other One of fixed, hinge, slider, rope, spring, groove, generic. |
softness_damping_ratio |
float | 1 |
The damping ratio of that spring; 1 settles without overshooting At least 0. |
softness_hz |
float | 1000000 |
How stiffly the joint's locked axes and limits are held, as a spring frequency in hertz; lower lets them stretch and spring back At least 0. |
Script functions
Methods of node.joint2d, the handle a node carrying this component exposes. Every handle also has get(), set(table), patch(table), has() and remove().
From physics2d:
| method | what it does |
|---|---|
joint_force() -> physics2d::JointForce |
The force and the torque the joint held through the last step. An articulation has none to read, and says so. |
joint_state() -> physics2d::JointState |
What the joint is doing. |
solve_ik(Vec2, physics2d::IkOptions?) |
Move a reduced-coordinates chain so its last link reaches a world position, leaving every joint inside its limits. Options: rotation (radians to turn the link to), constrain (the world axes to match: x, y, rotation; the translation by default, every axis when rotation is given), damping (1.0), iterations (10), tolerance (0.001). |