menu_bookDocumentation

Joint Components: HingeJoint Motor Modes, BreakForce, Body Resolution, and Joint Creation Timing

calendar_today May 4, 2026 schedule ~1 min read person patrickjr verified 50

Joint Components: HingeJoint, FixedJoint, and the Joint Base Class

s&box provides physics joint components for constraining physics bodies. All joints extend the Joint abstract base class.

Available Joint Types

Joint Base Properties

CSHARP
joint.Body = targetGameObject;       // the body to constrain
joint.AnchorBody = anchorGameObject; // the anchor (defaults to this GameObject)
joint.EnableCollision = false;       // allow collision between the two bodies
joint.BreakForce = 0f;               // linear force to break the joint (0 = unbreakable)
joint.BreakTorque = 0f;              // angular force to break the joint
joint.IsBroken                       // read-only: is the joint broken?
joint.LinearStress                   // current linear impulse on the joint
joint.AngularStress                  // current angular impulse on the joint
joint.OnBreak                        // Action callback when joint breaks

Breaking and Unbreaking

CSHARP
joint.Break();    // manually break the joint
joint.Unbreak();  // restore the joint

HingeJoint Motor Modes

CSHARP
// No motor (just friction)
hinge.Motor = HingeJoint.MotorMode.Disabled;
hinge.Friction = 0.5f;

// Spring to a target angle
hinge.Motor = HingeJoint.MotorMode.TargetAngle;
hinge.TargetAngle = 90f;
hinge.Frequency = 1.0f;
hinge.DampingRatio = 1.0f;

// Constant velocity motor
hinge.Motor = HingeJoint.MotorMode.TargetVelocity;
hinge.TargetVelocity = 180f;  // degrees per second
hinge.MaxTorque = 1000f;

// Angle limits
hinge.MinAngle = -90f;
hinge.MaxAngle = 90f;

// Read current state
float angle = hinge.Angle;
float speed = hinge.Speed;
Vector3 axis = hinge.Axis;

Body Resolution

Joint.FindPhysicsBody walks up the hierarchy to find a Rigidbody or Collider. If no body is found on the Body GameObject, the joint attaches to the world (a static reference body).

Joint Creation Timing

Joints are created in OnStart(), not OnEnabled(). This ensures both bodies exist before the joint is created. If Body or AnchorBody changes after start, the joint is recreated.

Was this helpful?