Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

README.md

phys.addJoint

Join two bodies with a validated joint. The joint kind is one of fixed, hinge, ball, prismatic, spring, rope, generic or rail (default fixed); entity names resolve to IDs and the anchor and axis vectors accept either {x,y,z} or array forms. A spring joint pulls its anchors toward restLength metres apart (default: their distance when it is built) with stiffness (default 100) and damping (default 10); on a hinge, ball or prismatic joint stiffness / damping are a spring back to where its frames align, which it carries only when they are given. Both are rejected on fixed and rope joints, which have no axis to spring. A rope joint is a hard maximum-distance limit (slack is free, taut resists extension) and requires maxDistance > 0 (meters between the anchor points). Either end may be a soft body (an entity with SoftBody): region anchors entity A's end and remoteRegion entity B's end on a region of its particles ({ box = { min, max } } or { nearest = point } in the entity's unit box), and a soft end with no region is anchored on the body as a whole. Joint limits: limitMin / limitMax bound a hinge's angle (degrees) or a prismatic's travel (metres), swingLimit / twistLimit hold a ball joint inside a cone and a twist (degrees), and axisLimits bounds single axes of any kind. A motor holds a velocity (motorMode = "velocity", motorVelocity) or pulls toward a target (motorMode = "position", motorTarget, motorStiffness, motorDamping), never past motorMaxForce; axisMotors drives single axes. collideConnected = false stops the two bodies colliding with each other (limbs, chain links). generic holds the axes lockedAxes names (linX, linY, linZ, angX, angY, angZ) and leaves the rest free. rail holds the first entity's localAnchor point to path, points in the second entity's local space (a coaster track, a train line, a zip line, a curved door track): free to run along it under gravity and forces, held across it; closed makes it a loop, ends = "open" lets the point run off an open end instead of stopping there, curve = "linear" makes straight runs between the points, friction resists sliding, and the motor drives the point along the path (motorVelocity in m/s, or motorTarget in metres along it). A body takes any number of joints: on a first entity that already carries one, the new joint is added under name (or joint2, joint3, ...), and an entity that is no body itself (a marker under a beam's end) joins the nearest body above it at its own position. Either pass both entities and an options table, or pass the first entity and put the second in the options as target. Returns the resolved ID of the first entity.