← Cheatsheets
Tags: unity, joints, physics, hinge, spring, fixed, configurable, ragdoll, constraints, game-dev
Last updated: 2026-06-27
Physics Joints & Constraints Cheatsheet
Quick Reference
| Joint Type | Movement | Rotation | Best For |
| FixedJoint | None | None | Glue two objects together (breakable) |
| HingeJoint | None | 1 axis | Doors, wheels, levers, pendulums |
| SpringJoint | Stretchy connection | Free | Bungee cords, elastic tethers |
| CharacterJoint | Limited all axes | Limited all axes | Ragdolls, articulated limbs |
| ConfigurableJoint | Fully customisable | Fully customisable | Anything (most powerful) |
FixedJoint
| Property | Description |
| Connected Body | Target Rigidbody to lock to |
| Break Force | Force threshold to break joint |
| Break Torque | Torque threshold to break joint |
| Enable Collision | Allow connected bodies to collide (usually false) |
# Create breakable attachment
FixedJoint joint = gameObject.AddComponent<FixedJoint>();
joint.connectedBody = targetRigidbody;
joint.breakForce = 500f;
joint.breakTorque = 200f;
void OnJointBreak(float breakForce) {
Debug.Log($"Joint broke at {breakForce}N");
}
HingeJoint
| Property | Description |
| Axis | Rotation axis (local space) |
| Anchor | Pivot point (local space) |
| Use Motor | Apply rotational force |
| Motor Target Velocity | Target angular speed (deg/s) |
| Motor Force | Torque to reach target |
| Use Limits | Restrict rotation angle |
| Limits (min/max) | Min/max angle in degrees |
| Use Spring | Spring-back to target position |
HingeJoint hinge = gameObject.AddComponent<HingeJoint>();
hinge.connectedBody = doorFrameRigidbody;
# Motor (spinning)
hinge.useMotor = true;
JointMotor motor = hinge.motor;
motor.targetVelocity = 360f;
motor.force = 100f;
hinge.motor = motor;
# Limits (door with 90° opening)
hinge.useLimits = true;
JointLimits limits = hinge.limits;
limits.min = 0f;
limits.max = 90f;
hinge.limits = limits;
# Spring (self-closing door)
hinge.useSpring = true;
JointSpring spring = hinge.spring;
spring.spring = 100f;
spring.damper = 10f;
spring.targetPosition = 0f;
hinge.spring = spring;
SpringJoint
| Property | Description |
| Spring | Tension stiffness (higher = tighter) |
| Damper | Oscillation damping (higher = less bounce) |
| Min Distance | Minimum unstretched length |
| Max Distance | Maximum stretch length |
SpringJoint spring = gameObject.AddComponent<SpringJoint>();
spring.connectedBody = targetRigidbody;
spring.spring = 50f;
spring.damper = 5f;
spring.minDistance = 0f;
spring.maxDistance = 3f;
CharacterJoint
| Property | Description |
| Swing Axis | Primary rotation axis |
| Twist Limit Spring | Spring for twist constraint |
| Low Twist Limit | Min twist angle with bounciness |
| High Twist Limit | Max twist angle with bounciness |
| Swing 1 Limit | First swing axis (usually Y) |
| Swing 2 Limit | Second swing axis (usually Z) |
| Enable Projection | Snap back if bodies separate too far |
Ragdoll Setup
Step-by-Step
- Select the character’s bone hierarchy in the Hierarchy.
- GameObject → 3D Object → Ragdoll… (Unity wizard).
- Assign each bone: Pelvis, Spine, Head, Arms, Legs.
- Unity auto-adds CharacterJoints, Colliders, and Rigidbodies.
- Tune collider sizes to roughly match body parts.
- Tweak joint limits: Twist -20 to 20 (knees/elbows more restrictive), Swing -45 to 45 for most limbs.
Ragdoll Activation Script
public void EnableRagdoll() {
foreach (Rigidbody rb in GetComponentsInChildren<Rigidbody>()) {
rb.isKinematic = false;
rb.useGravity = true;
}
foreach (Collider col in GetComponentsInChildren<Collider>())
col.enabled = true;
GetComponent<Animator>().enabled = false;
GetComponent<Collider>().enabled = false;
GetComponent<Rigidbody>().isKinematic = true;
}
public void DisableRagdoll() {
foreach (Rigidbody rb in GetComponentsInChildren<Rigidbody>())
rb.isKinematic = true;
foreach (Collider col in GetComponentsInChildren<Collider>())
col.enabled = false;
GetComponent<Animator>().enabled = true;
GetComponent<Collider>().enabled = true;
}
ConfigurableJoint
| Property | Description |
| Connected Body | Target Rigidbody |
| Anchor | Pivot in local space |
| Axis | Primary axis direction |
| X/Y/Z Motion | Locked / Limited / Free |
| Angular X/Y/Z Motion | Locked / Limited / Free |
| Target Position / Velocity | Drives linear motion |
| Target Rotation / Angular Velocity | Drives angular motion |
Replicating Joint Types
| Desired Joint | Config |
| FixedJoint | All Linear/Angular Motion = Locked |
| HingeJoint | Angular X Motion = Limited, rest = Locked |
| SpringJoint | Linear Y Motion = Limited (with spring) |
ConfigurableJoint joint = gameObject.AddComponent<ConfigurableJoint>();
joint.connectedBody = targetRigidbody;
# Hinge-like
joint.angularXMotion = ConfigurableJointMotion.Limited;
joint.angularYMotion = ConfigurableJointMotion.Locked;
joint.angularZMotion = ConfigurableJointMotion.Locked;
SoftJointLimit limit = new SoftJointLimit();
limit.limit = 90f;
joint.angularXLimit = limit;
JointDrive drive = new JointDrive();
drive.positionSpring = 100f;
drive.positionDamper = 10f;
joint.angularXDrive = drive;
Joint Performance
- Joints are more expensive than simple colliders.
- Keep joint chains under ~20 bones for real-time ragdolls.
- Disable unused joints (e.g. disable ragdoll when alive).
- Use FixedJoint instead of parenting for breakable connections.
- Lower solverIterations on low-priority joint chains.