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