You’d like to understand Godot’s Joint2D
nodes.
Joint are used to constrain the movement of attached physics objects. For any joint node, you need to attach two bodies, which must extend from PhysicsObject2D
.
These properties are common to all joint nodes:
0
.true
.There are three types of Joint2D. In all of the following examples, there is one RigidBody2D
connected via a joint to a StaticBody2D
. “Visible Collision Shapes” is enabled in the screen images below so you can see a representation of the joint.
The “pin” joint attaches the two bodies at a single point, allowing them to freely rotate.
The pin joint’s Softness property gives some “springiness” to the connection. The value can range from 0
(the default) which allows no movement, to 16
.
This joint connects the two bodies with a spring-like force.
The spring’s behavior can be adjusted with these properties:
This joint constrains the attached bodies to move linearly.
By default, the groove runs vertically, but you can change this by rotating the groove node.
These properties control the groove’s behavior:
You can download an example project to play with these joints here: physics_joints.zip