Various issues with Jolt fixed joint

Hello there,

I’m new in Godot and Jolt but quite experimented in physics engines and game dev.

I cannot create a fixed joint in GD.

Apparently there is no api for the jolt fixed constraint: Jolt Fixed Constraint Component | ezEngine

I tried to do that with a Generic6DOFJoint3D with this function:

func _create_joint() → bool:

  if not parent_block or not child_block:
    return false

  # Use Generic6DOFJoint3D with all axes locked
  var dof_joint = Generic6DOFJoint3D.new()

  # Set joint frame before limits
  if parent_slot:
	dof_joint.global_transform = parent_slot.global_transform
  else:
	dof_joint.global_position = (parent_block.global_position + child_block.global_position) / 2.0

  dof_joint.node_a = parent_block.get_path()
  dof_joint.node_b = child_block.get_path()

  # Lock all linear axes (X, Y, Z) to 0
  dof_joint.set_flag_x(Generic6DOFJoint3D.FLAG_ENABLE_LINEAR_LIMIT, true)
  dof_joint.set_param_x(Generic6DOFJoint3D.PARAM_LINEAR_LOWER_LIMIT, 0.0)
  dof_joint.set_param_x(Generic6DOFJoint3D.PARAM_LINEAR_UPPER_LIMIT, 0.0)

  dof_joint.set_flag_y(Generic6DOFJoint3D.FLAG_ENABLE_LINEAR_LIMIT, true)
  dof_joint.set_param_y(Generic6DOFJoint3D.PARAM_LINEAR_LOWER_LIMIT, 0.0)
  dof_joint.set_param_y(Generic6DOFJoint3D.PARAM_LINEAR_UPPER_LIMIT, 0.0)

  dof_joint.set_flag_z(Generic6DOFJoint3D.FLAG_ENABLE_LINEAR_LIMIT, true)
  dof_joint.set_param_z(Generic6DOFJoint3D.PARAM_LINEAR_LOWER_LIMIT, 0.0)
  dof_joint.set_param_z(Generic6DOFJoint3D.PARAM_LINEAR_UPPER_LIMIT, 0.0)

  # Lock all angular axes (X, Y, Z) to 0
  dof_joint.set_flag_x(Generic6DOFJoint3D.FLAG_ENABLE_ANGULAR_LIMIT, true)
  dof_joint.set_param_x(Generic6DOFJoint3D.PARAM_ANGULAR_LOWER_LIMIT, 0.0)
  dof_joint.set_param_x(Generic6DOFJoint3D.PARAM_ANGULAR_UPPER_LIMIT, 0.0)

  dof_joint.set_flag_y(Generic6DOFJoint3D.FLAG_ENABLE_ANGULAR_LIMIT, true)
  dof_joint.set_param_y(Generic6DOFJoint3D.PARAM_ANGULAR_LOWER_LIMIT, 0.0)
  dof_joint.set_param_y(Generic6DOFJoint3D.PARAM_ANGULAR_UPPER_LIMIT, 0.0)

  dof_joint.set_flag_z(Generic6DOFJoint3D.FLAG_ENABLE_ANGULAR_LIMIT, true)
  dof_joint.set_param_z(Generic6DOFJoint3D.PARAM_ANGULAR_LOWER_LIMIT, 0.0)
  dof_joint.set_param_z(Generic6DOFJoint3D.PARAM_ANGULAR_UPPER_LIMIT, 0.0)

  # Exclude collisions between attached blocks
  dof_joint.exclude_nodes_from_collision = true

  joint = dof_joint
  add_child(joint)

  return true

The result is that linear axis y and z are not constrained, but completely free.

I also tried with a hinge joint with limit without success.

Does somebody see something wrong in my code?

Thank you in advance

Maybe a slider joint with a very small motion limit would be easier? SliderJoint3D — Godot Engine (stable) documentation in English

1 Like

UPDATE - SOLVED:

The issue was not with the joint configuration itself, but with the scene hierarchy.

Root cause: The joint (or its parent BlockAttachment node) was being added as a child of one of the RigidBody3D bodies it was trying to constrain. According to Godot docs, having “RigidBody3D as the descendant of a constantly moving node” causes unpredictable behaviors.

Solution:

  1. Add the joint node as a sibling to both RigidBody3D (not as a child)

  2. Proper operation order:

    • Create joint

    • add_child(joint) to scene root (or a Node3D container)

    • Set global_position/global_transform

    • Set node_a/node_b paths

    • await get_tree().process_frame for stabilization

    • Configure limits/flags

Correct hierarchy:

scene_root/
├─ RigidBodyA
├─ RigidBodyB
└─ Joint (connects A & B)

This fixed the Y/Z linear constraint issue completely. All 6 DOF now lock properly.