Constraint

From Valve Developer Community
Jump to: navigation, search
Merge-arrows.png
It has been suggested that this article or section be merged into Physics Entity Overview. (Discuss)

A constraint is an entity that restricts the movement one or more VPhysics entities relative to the world or each other.

Note.pngNote:Constraints attach to a physics object's center of mass. To have them attach at specific points use info_constraint_anchor.
Tip.pngTip:To constrain an object to the world, leave one of the target fields blank. The position of the constraint entity will then be used.

To constrain QPhysics objects, use parenting.

Simple constraints

phys_constraint
Prevents its targets from moving relative to each other.
phys_lengthconstraint
Limits how far its target(s) can move.
phys_keepupright
Tries to ensure that an object stays upright. Can look very wrong so use with care!
phys_ballsocket
Prevents movement but allows free rotation.
phys_hinge
Prevents movement but allows rotation along a single axis.
phys_slideconstraint
Restricts movement to a single axis.

Complex constraints

phys_pulleyconstraint
Essentially two length constraints with a shared length.
phys_ragdollconstraint
A ball socket with rotation limits.
phys_spring
A rigid length constraint with bounciness.

Utilities

phys_constraintsystem
Manages a group of overlapping constraints and keeps them stable.
info_constraint_anchor
Used to attach constraints to a local position on an entity (usually they attach to the center of mass). Attach the desired constraint to this entity, and then parent this entity to the entity you want the constraint to apply to.

See also