How to implement a fixed joint in Godot?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gazer500

I want to connect two rigid bodies together using the PinJoint2D node, but I want it to work so that one object only moves if the other is moving, and it moves/rotates the exact same way as that object. Unity has something like this called a FixedJoint, and I want to know if there’s a way to implement something similar in Godot.

Idk if Godot has something similar, but can’t you just use parenting? Even the Unity docs say that it’s just like parenting, but using physics instead: Unity - Manual: Fixed Joint component reference

Bernard Cloutier | 2021-11-25 20:11

We kinda can use parenting to simulate fixedjoint, we can set staticbody2D as the child of rigidbody2D, and the staticbody acts as it is welded to rigidbody2D, but we can’t weld rigidbody2D to another rigidbody2D by setting it as the child of rigidbody2D ):

Kushal | 2022-01-15 16:53

:bust_in_silhouette: Reply From: bath_idea

I’d like to share, how to create fixed joint in godot.
Obviously ,we can’t just parent a rigidbody to another rigidbody for creating fixed joint.
a child rigidbody will lost rigidbody property.

We can create compound object. Actually, it is a rigidbody with multiple collision shape.
example.
-Rigid_A
|->Collision_Shape_A
|----->Mesh_A
|->Collision_Shape_B
|----->Mesh_B

On runtime, we can just move only collision_shape and Mesh of rigidbody B to be under Rigidbody A.

Hope this help.

:bust_in_silhouette: Reply From: bath_idea

I have another simple solution. Just use Generic6DOFJoint. The default of joint has angle limited. So it will work like fixed joint. Hope this help.