Fixed Joint is a rigid constraint component that completely restricts the relative motion between two colliders. When two objects are connected by a fixed joint, they maintain their relative position and orientation as if glued together rigidly.
When adding a joint component, make sure the target entity already has a Dynamic Collider component attached. If not, the editor will automatically add a Dynamic Collider Component
for you.
If the target is a collider, the target entity needs to have a collider component (Dynamic Collider, Static Collider, Character Controller) attached.
anchor
Defines the anchor point position on the main collider, using local coordinates. This point defines the joint's connection position.
connectedAnchor
Defines the connection point position. Its meaning depends on the connectedCollider setting:
automaticConnectedAnchor
Whether to automatically calculate the connectedAnchor value. When enabled, the system automatically sets the connection point to maintain initial relative positions. Set to false for manual precise control of the connection point.
breakForce
Maximum force the joint can withstand before breaking. Set to Infinity for an unbreakable joint. This property can be used to simulate destructible connections between objects.
breakTorque
Maximum torque the joint can withstand before breaking. Set to Infinity for an unbreakable joint. Used in conjunction with breakForce to simulate more realistic connection destruction.
// Add fixed joint component
const fixedJoint = entity.addComponent(FixedJoint);
// Set the connected collider
fixedJoint.connectedCollider = targetEntity.getComponent(Collider);
// Set anchor point
fixedJoint.anchor.setValue(0, 1, 0);
// Set connection point
fixedJoint.automaticConnectedAnchor = false;
fixedJoint.connectedAnchor.setValue(0, 0, 0);
// Set break conditions
fixedJoint.breakForce = 1000; // Break force
fixedJoint.breakTorque = 1000; // Break torque
// Set as unbreakable
fixedJoint.breakForce = Infinity;
fixedJoint.breakTorque = Infinity;
// Adjust mass influence
fixedJoint.massScale = 1.5; // Increase own mass influence
fixedJoint.connectedMassScale = 0.5; // Decrease connected object's mass influence