terminalCode Example

Physics joints — Fixed, Ball, Hinge, Slider, Spring, and Wheel

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

Physics Joints

Joints connect two physics bodies together with constraints. All joint types are components added to a GameObject positioned at the joint's anchor point.

Joint Types

TypeDescription
FixedJointLocks two bodies together rigidly
BallJointAllows rotation in all axes (ball-and-socket)
HingeJointRotation around one axis (doors, wheels)
SliderJointLinear movement along one axis (pistons)
SpringJointElastic connection with configurable stiffness
WheelJointCombined hinge + suspension for vehicles

Basic Setup

CSHARP
// All joints need two bodies: the joint's own GO body and an anchor body.
// Position the joint GO at the connection point.

var joint = gameObject.Components.Create<HingeJoint>();
joint.Body       = doorGameObject;        // the body being constrained
joint.AnchorBody = frameGameObject;       // what it's attached to (null = world)
joint.Strength   = 0f;                    // 0 = rigid, >0 = breakable

Hinge Joint (Door)

CSHARP
public sealed class Door : Component
{
    protected override void OnStart()
    {
        var hinge = Components.Create<HingeJoint>();
        hinge.Body       = Components.Get<Rigidbody>().GameObject;
        hinge.AnchorBody = frameObject;
        // Axis defaults to local Z — set GO rotation to align the hinge axis
    }
}

Spring Joint

CSHARP
var spring = gameObject.Components.Create<SpringJoint>();
spring.Body         = objectA;
spring.AnchorBody   = objectB;
spring.Strength     = 500f;   // spring stiffness

Wheel Joint (Vehicle)

CSHARP
var wheel = axleObject.Components.Create<WheelJoint>();
wheel.Body         = wheelObject;
wheel.AnchorBody   = chassisObject;
wheel.Strength     = 1000f;         // suspension strength

Breaking Joints

Set Strength to a positive value — the joint breaks when force exceeds it:

CSHARP
joint.Strength        = 2000f;  // breaks at 2000 force units
joint.AngularStrength = 500f;   // separate limit for torque

Checking if a Joint is Broken

CSHARP
public sealed class BreakableJoint : Component
{
    HingeJoint Joint { get; set; }

    protected override void OnUpdate()
    {
        if ( Joint == null || !Joint.IsValid() )
        {
            Log.Info( "Joint broke!" );
        }
    }
}
Was this helpful?