Skip to Content
Kinemium

HingeConstraint

Join two attachments with a powered rotating hinge.

HingeConstraint connects two attachments and allows rotation around one axis. It can act as a free hinge, a motor, or a servo with angle limits.

Getting started

local hinge = Instance.new("HingeConstraint")
hinge.Attachment0 = frame.Attachment
hinge.Attachment1 = door.Attachment
hinge.LimitsEnabled = true
hinge.LowerAngle = -90
hinge.UpperAngle = 0
hinge.Parent = door

Properties

PropertyTypeAccessDefaultDescription
Attachment0Attachment?Read/writenilFirst anchor.
Attachment1Attachment?Read/writenilSecond anchor.
EnabledbooleanRead/writetrueWhether the hinge simulates.
VisiblebooleanRead/writefalseDraw the hinge gizmo.
ColorBrickColorRead/writeGreenGizmo color.
RadiusnumberRead/write0.15Gizmo radius.
ActuatorTypeEnum.ActuatorTypeRead/writeNoneFree, motor, or servo behavior.
LimitsEnabledbooleanRead/writefalseApply the angle limits.
LowerAnglenumberRead/write-45Lower limit in degrees.
UpperAnglenumberRead/write45Upper limit in degrees.
AngularVelocitynumberRead/write0Target motor speed.
MotorMaxTorquenumberRead/write0Motor torque limit.
MotorMaxAccelerationnumberRead/write500000Motor acceleration limit.
ServoMaxTorquenumberRead/write0Servo torque limit.
TargetAnglenumberRead/write0Servo target in degrees.
AngularSpeednumberRead/write0Servo speed limit.
AngularResponsivenessnumberRead/write45Servo responsiveness.
SoftlockServoUponReachingTargetbooleanRead/writefalseHold the servo at its target.
RestitutionnumberRead/write0Bounce when hitting a limit.
CurrentAnglenumberRead-only0Current hinge angle in degrees.

Numeric properties accept finite values and raise an error for NaN. CurrentAngle and Active are read-only.

Actuator types

  • None lets the hinge rotate freely within its limits.
  • Motor drives toward AngularVelocity, limited by MotorMaxTorque and MotorMaxAcceleration.
  • Servo drives toward TargetAngle, limited by ServoMaxTorque and AngularSpeed.

With limits enabled, the servo target is clamped to the allowed range. SoftlockServoUponReachingTarget stops the servo once the error is tiny.

Limits and restitution

LowerAngle and UpperAngle are in degrees and can be given in either order; the hinge uses the smaller as the lower bound. When Restitution is above zero, the hinge rebounds off a limit with a fraction of the incoming speed instead of stopping dead.

Notes

  • Both attachments need parts in the same world, and at least one part must be movable.
  • Assigning a non-attachment to an attachment property is ignored.
  • The gizmo only renders when Visible is true and the anchors are valid.
  • Cloning copies the configuration but starts inactive.

See also

  • Constraint for the shared attachment properties.
  • SpringConstraint for a linear connection.
  • Attachment for placing the hinge axis.

On this page