Mechanical constraints behave as conceptual mechanical connections such as hinges, springs, and motors.
import ConstraintVisualization from '../includes/studio/constraint-visualization.md'
import ConstraintSimulation from '../includes/studio/constraint-simulation.md'
The physics engine includes the following Class.Constraint|Constraints that behave as conceptual mechanical connections, including hinges, springs, ropes, and more. In addition, various mover constraints are available to exert directional or rotational force upon assemblies.
`Class.BallSocketConstraint` forces its two attachments into the same position and allows them to freely rotate about all three axes, with optional limits to restrict both tilt and twist`Class.HingeConstraint` allows its two attachments to rotate about one axis, with optional assigned power for motor or servo behavior`Class.PrismaticConstraint` allows two attachments to slide along one axis but not rotate, with optional assigned power for mechanisms like sliding doors and elevator platforms`Class.CylindricalConstraint` allows its attachments to slide along one axis and rotate about another axis, with optional assigned angular and/or linear power`Class.SpringConstraint` applies a force on its attachments based on spring and damper behavior, with an optional minimum/maximum length`Class.TorsionSpringConstraint` applies torque based on a relative angle and relative angular velocity, in an attempt to bring two axes from two parts together`Class.UniversalConstraint` ensures two axes on two assemblies remain perpendicular, useful for applications such as vehicle power transmission to rear drive shafts, robotics, and more`Class.RopeConstraint` prevents two attachments from separating further than a defined length, with optional behavior as an extending or contracting winch`Class.RodConstraint` keeps two attachments separated by a defined length, with optional limits on rotational tilt`Class.PlaneConstraint` moves two attachments into a position/orientation along a plane, and both attachments remain free to translate and rotate unless otherwise constrained`Class.WeldConstraint` connects two `Class.BasePart|BaseParts` and ensures they stay in the same relative position and orientation to each other, even if they are not touching`Class.RigidConstraint` connects two `Class.Attachment|Attachments` or `Class.Bone|Bones` and ensures they stay in the same relative position/orientation to each other, even if they are not touching`Class.NoCollisionConstraint` prevents collisions between two specific parts, but those parts may still register collisions with the rest of the world
Constraint visualization
Create constraints
All mechanical constraints must connect one or two Class.Attachment|Attachments or Class.Bone|Bones, except for WeldConstraint and NoCollisionConstraint. When connected to Class.Bone|Bones, the constraint will use their animated position and orientation.
To create a mechanical constraint, you can either insert one from the Constraint picker/button or through the Explorer window.
In Studio's Model tab toolbar, click‑hold over the small corner arrow on a constraint button to open its picker menu, then select the desired constraint.
In the 3D viewport, hover over any Class.Part or Class.MeshPart and click to add a new Class.Attachment to the part at the visualized point. Alternatively, hover over and click an existing Class.Attachment or Class.Bone to use it for the constraint.
Most mechanical constraints require a secondary attachment in their functionality, so the tool will typically prompt you to repeat the previous step on another Class.Part, Class.MeshPart, Class.Attachment, or Class.Bone.
Completed [SpringConstraint](../physics/constraints/spring.md) connecting two attachments
Note that [WeldConstraint](../physics/constraints/weld.md) and [NoCollisionConstraint](../physics/constraints/no-collision.md) do not utilize `Class.Attachment|Attachments` or `Class.Bone|Bones`, so their linking properties in the following steps are **Part0**/**Part1**, not **Attachment0**/**Attachment1**. Similarly, you'll need to select a `Class.Part` or `Class.MeshPart` to complete the link, not an `Class.Attachment` or `Class.Bone`.
In the Explorer hierarchy, hover over the intended parent, click the ⊕ button, and insert the desired constraint from the dropdown menu, such as a SpringConstraint.
With the new constraint selected, locate its currently empty Attachment0 property in the Properties window.
Link the Attachment0 property to an Class.Attachment or Class.Bone in two consecutive steps:
In the Properties window, click in the Attachment0 row to reveal the selection cursor.
In the Explorer hierarchy, click on the target Class.Attachment or Class.Bone.
Most mechanical constraints require a secondaryClass.Attachment or Class.Bone in their functionality. If necessary, repeat the previous step on the Attachment1 property in the Properties window.