joint2d component
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.…
이 페이지의 내용
2d · physics · 28 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 |
articulation |
bool | false |
Solve in reduced coordinates: the chain never drifts and can be solved for inverse kinematics, but cannot close a loop or break |
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 |
break_force |
float | 0 |
The force, in newtons, that snaps the joint and calls on_joint_break; 0 never breaks. Does not apply to an articulation At least 0. |
break_torque |
float | 0 |
The torque about the anchor, in newton metres, that snaps the joint; 0 never breaks. Does not apply to an articulation At least 0. |
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 |
coupled_translation |
flags | [] |
Free linear axes tied into one distance, whose limit and motor come from the first of them; a rope and a spring couple both already One of x, y. |
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 |
gear_offset |
float | 0 |
Where this joint stands when the gear_with joint is at 0 |
gear_ratio |
float | 1 |
How far this joint turns or slides per unit of the gear_with joint's |
gear_with |
node | — | On an articulation: another joint node of the same chain this joint follows, its first free axis tied to that joint's first free axis |
kind |
enum | fixed |
How the two bodies may move relative to each other One of fixed, hinge, slider, rope, spring, groove, generic. |
kinematic_link |
bool | false |
On an articulation: the solver never changes this joint's velocity, so the link holds its pose against its parent and moves only by solve_ik |
lock_rotation |
bool | false |
Stop a generic joint turning |
lock_translation |
flags | [] |
The axes a generic joint may not slide along One of x, y. |
max_length |
float | 0 |
The rope's greatest length At least 0. |
passive_rest |
float | 0 |
On an articulation: where that spring rests, in radians about a rotation axis and units along a linear one |
passive_stiffness |
float | 0 |
On an articulation: a spring on each free axis pulling it towards passive_rest; 0 is none At least 0. |
rest_length |
float | 0 |
The length a spring pulls back to At least 0. |
self_collision |
bool | true |
On an articulation: let the chain's links collide with each other. One setting for the whole chain, off when any of its joints says off |
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() -> any |
The force and the torque the joint held through the last step, #{ force, torque }. An articulation has none to read, and says so. |
joint_state() -> any |
What the joint is doing: #{ status, angle, limit_impulses, motor_impulses, coordinates, velocities }, as in 3D: status is enabled, disabled, body_disabled or waiting; angle is a hinge's turn in radians; an articulation adds each free axis's coordinate and velocity. |
remove_joint() |
Undo the node's joint, leaving both bodies free. |
set_joint_limits(string, float, float) |
Set how far one of the joint's free axes may travel; equal values lift the limit. Rewrites that axis's axes record. |
set_motor_position(string, float, float, float) |
Drive one of the joint's free axes towards an angle or a distance, with a spring's stiffness and damping. Rewrites that axis's axes record. |
set_motor_velocity(string, float, float) |
Drive one of the joint's free axes towards a speed: how a wheel is powered. Rewrites that axis's axes record. |
solve_ik(float, float, any?) |
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). |