Mechanical Constraints

The physics engine includes several Constraints that behave as real or conceptual mechanical connections, including hinges, springs, motors, ropes, and more. This article outlines every mechanical constraint and how to create them using Studio's Create button drop-down.

Creating Constraints

All mechanical constraints must connect two Attachments, except when noted. To create a constraint using the Create tool workflow:

  1. (Optional) Enable all of the constraint visualization options from the Model tab.

  2. Access the Create button's drop-down menu and select the desired constraint type.

  3. On one part, click to place the first attachment and then, on the other part, click to place the second attachment. This completes the connection with the chosen constraint type.

Constraint Details

Ball in Socket

A BallSocketConstraint forces its two attachments into the same position and allows them to freely rotate about all three axes. However, you can enable limits to restrict both tilt and twist.

Limits

You can set limits to restrict both tilt and twist of a ball socket, similar to how a human's head can tilt and turn within a limited axial range. Enabling the LimitsEnabled property exposes the UpperAngle value to restrict tilt within a cone; it also exposes the TwistLimitsEnabled property which, when enabled, lets you restrict twist rotation through the TwistLowerAngle and TwistUpperAngle limits.

UpperAngle = 30

TwistLimitsEnabled = true

Enabling LimitsEnabled also exposes the Restitution value which defines the elasticity of the attachments at their tilt and/or twist limits.

Hinge

A HingeConstraint allows its two attachments to rotate about one axis, forcing them into the same position and X axis alignment. The constraint can also be powered to behave like a motor or servo, and you can set limits to restict the hinge's rotational range.

Angular Power

If a hinge's ActuatorType is set to Motor, it attempts to rotate the attachments with the goal of reaching its AngularVelocity. You can further control this rotation through both MotorMaxAcceleration and MotorMaxTorque.

If a hinge's ActuatorType is set to Servo, it attempts to rotate to an angle specified by TargetAngle. This rotation is controlled by both AngularSpeed and ServoMaxTorque.

ActuatorType = Motor

ActuatorType = Servo

Limits

You can set limits to restrict the rotation of a hinge, useful for mechanisms like doors which should only swing open or closed within a set range. Enabling the LimitsEnabled property exposes the LowerAngle and UpperAngle limits, as well as Restitution which defines the elasticity of the attachments when they reach either limit.

Prismatic

A PrismaticConstraint creates a rigid joint between two attachments, allowing them to slide along one axis but not rotate. The constraint can also be powered for mechanisms like sliding doors and elevator platforms.

Linear Power

If a prismatic's ActuatorType is set to Motor, it attempts to translate the attachments with the goal of reaching Velocity. You can further control this translation through both MotorMaxAcceleration and MotorMaxForce.

If a prismatic's ActuatorType is set to Servo, it attempts to translate the attachments to a set separation specified by TargetPosition. This translation is controlled by Speed, LinearResponsiveness, and ServoMaxForce.

ActuatorType = Motor

ActuatorType = Servo

Limits

You can set limits to restrict the slide range a prismatic. Enabling the LimitsEnabled property exposes the LowerLimit and UpperLimit values, as well as Restitution which defines the elasticity of the attachments when they reach either limit.

Cylindrical

A CylindricalConstraint allows its attachments to slide along one axis and rotate about another axis. This constraint, along with a Spring, is ideal for building vehicle suspensions where the wheel shock can slide up and down while the wheel itself spins. The constraint can also be powered.

Angular Power

If a cylindrical's AngularActuatorType is set to Motor, it attempts to rotate the attachments with the goal of reaching its AngularVelocity. You can further control this rotation through both MotorMaxAngularAcceleration and MotorMaxTorque.

If a cylindrical's AngularActuatorType is set to Servo, it attempts to rotate to an angle specified by TargetAngle. This rotation is controlled by AngularSpeed, AngularResponsiveness, and ServoMaxTorque.

Linear Power

If a cylindrical's ActuatorType is set to Motor, it attempts to translate the attachments with the goal of reaching Velocity. You can further control this translation through both MotorMaxAcceleration and MotorMaxForce.

If a cylindrical's ActuatorType is set to Servo, it attempts to translate the attachments to a set separation specified by TargetPosition. This translation is controlled by Speed, LinearResponsiveness, and ServoMaxForce.

Limits

You can set limits to restrict both the slide range and rotation of a cylindrical constraint.

Enabling the LimitsEnabled property exposes the LowerLimit and UpperLimit values, as well as Restitution which defines the elasticity of the attachments when they reach either limit.

Enabling the AngularLimitsEnabled property exposes the LowerAngle and UpperAngle limits, as well as AngularRestitution which defines the elasticity of the attachments when they reach either limit.

LimitsEnabled = true

AngularLimitsEnabled = true

Inclination Angle

InclinationAngle defines the direction of the rotation axis as an angle from the X axis in the X/Y plane of Attachment0, from -180 to 180. This lets you tilt the rotating element without changing the sliding axis.

InclinationAngle = 90

InclinationAngle = 30

Spring

A SpringConstraint applies a force to its attachments based on spring and damper behavior. You can customize a spring's damping and stiffness, as well as set minimum and maximum limits on the spring's length.

Free Length

FreeLength defines the natural resting length of the spring. If the attachments are further apart than the free length, they are forced together; if the attachments are closer together than the free length, they are forced apart.

Damping

The Damping value controls how fast the spring's oscillation dies down. A value of 0 allows the spring to oscillate endlessly, while higher values bring the spring to a rest more quickly.

Stiffness

Stiffness sets the strength of the spring. Higher values create a spring that responds with more force when its attachments are closer together or further apart than FreeLength.

Stiffness = 25

Stiffness = 500

Limits

Enabling the LimitsEnabled property exposes the MinLength and MaxLength values for setting the minimum and maximum length of the spring. If the spring's attachments reach these limits, they stop moving apart from one another without restitution.

Torsion Spring

A TorsionSpringConstraint applies torque based on a relative angle and relative angular velocity. It attempts to bring two axes from two parts together and is useful for hinged swinging doors with a spring-back effect.

Damping

The Damping value controls how fast the spring's oscillation dies down. A value of 0 allows the spring to oscillate endlessly, while higher values bring the spring to a rest more quickly.

Damping = 0

Damping = 50

Stiffness

Stiffness sets the torsional strength of the spring. Higher values create a spring that responds with more force.

Limits

Enabling the LimitsEnabled property exposes the MaxAngle value to restrict the spring's range within a cone; it also exposes the Restitution value which defines the elasticity of the attachments when they reach their limit.

Universal

A UniversalConstraint ensures two axes on two bodies remain perpendicular. Example applications include vehicle power transmission to the rear drive shafts, robotics, etc.

Orientation of a universal's attachments affects how it will move. To ensure it behaves correctly, the SecondaryAxis of the attachments — visualized by the orange arrows — should be perpendicular to each other. Note that a green L-shaped indicator appears when the axes are properly oriented.

Secondary axes perpendicular
Secondary axes misoriented

Limits

Enabling the LimitsEnabled property exposes the MaxAngle limit to restrict tilt within a cone, as well as Restitution which defines the elasticity of the attachments when they reach the limit.

Rope

A RopeConstraint prevents two attachments from separating further than a defined Length. The attachments can move closer together than this length and both can freely rotate. Restitution defines the elasticity of the attachments when they reach the separation limit specified by Length.

This constraint can also be powered to behave as a motorized winch.

Winch

If a rope's WinchEnabled property is enabled, it attempts to translate the attachments to a set separation specified by WinchTarget, effectively the target length of the rope in studs. This translation is controlled by WinchSpeed, WinchResponsiveness, and WinchForce.

Rod

A RodConstraint keeps two attachments separated by its defined Length. By default, both attachments can rotate freely, although you can enable limits to restrict rotational tilt.

Limits

You can limit rotation of the attachments within a cone, independently of each other, by enabling the LimitsEnabled property and setting LimitAngle0 and LimitAngle1 respectively.

Plane

A PlaneConstraint moves its Attachment0 and Attachment1 into a position/orientation along a plane whose normal vector is the primary axis of Attachment0. Both parent assemblies remain free to translate and rotate unless otherwise constrained.

Compare the following examples for how the orientation of Attachment0 defines the plane (the orientation of Attachment1 has no bearing).

Orientation = (0, 0, 90)
Orientation = (-45, 0, 90)

Weld

A WeldConstraint attaches two BaseParts together and ensures they stay in the same relative position and orientation to each other. Even if the two parts are not touching, you can weld them together.

Rigid

A RigidConstraint connects its Attachment0 and Attachment1 with zero offset. Because it directly connects two attachments instead of two BaseParts, it is useful for attaching accessories to avatar rigs using the rig's own attachments.

No Collision

The NoCollisionConstraint prevents collisions between two specific parts, but those parts may still register collisions with the rest of the world. Compared to collision groups, it provides a direct way to disable specific collisions, such as the wheel of a car scraping against the car's body.

Simulating Constraints While Dragging

To simulate constraints while moving or rotating parts, you can switch to Physical mode in the Model tab. This forces parts to obey physical limitations defined by their constraints. For example, if two parts are attached by a Rope and you drag one part around the scene, the other part will follow as the rope becomes taut.