Skip to Content
Kinemium

SpringConstraint

Pull two attachments together with adjustable stiffness and damping.

SpringConstraint connects two attachments with a spring. It can also render a coil between them and limit the travel distance.

Getting started

local spring = Instance.new("SpringConstraint")
spring.Attachment0 = base.Attachment
spring.Attachment1 = platform.Attachment
spring.Stiffness = 400
spring.Damping = 40
spring.FreeLength = 2
spring.Visible = true
spring.Parent = platform

Properties

PropertyTypeAccessDefaultDescription
Attachment0Attachment?Read/writenilFirst anchor.
Attachment1Attachment?Read/writenilSecond anchor.
StiffnessnumberRead/write0Spring strength. Higher pulls harder.
DampingnumberRead/write0Resistance to relative motion.
FreeLengthnumberRead/write1Length at which the spring applies no force.
MaxForcenumberRead/writeinfMaximum force the spring can apply.
MinLengthnumberRead/write0Lower travel limit when limits are enabled.
MaxLengthnumberRead/write5Upper travel limit when limits are enabled.
LimitsEnabledbooleanRead/writefalseWhether the min and max lengths apply.
StandbooleanRead/writefalseKeep the coil standing along its axis instead of sagging.
VisiblebooleanRead/writefalseWhether the coil is drawn.
CoilsnumberRead/write3Number of rendered coils, clamped to 0 through 8.
ColorBrickColorRead/writeLemon metalicColor of the rendered coil.
RadiusnumberRead/write0.4Radius of the rendered coil.
ThicknessnumberRead/write0.1Line thickness of the rendered coil.
CurrentLengthnumberRead-only0Distance between the anchors.
ActivebooleanRead-onlyfalseWhether the spring is simulating.

Numeric properties other than Coils clamp to 0 or above. Assigning NaN raises an error. MinLength and MaxLength rebuild the joint when they change.

Methods

SignatureDescription
GetDebugAppliedForce(index: number): Vector3Returns the last force applied at end 0 or 1.
GetDebugAppliedTorque(index: number): Vector3Returns the last torque applied at end 0 or 1.

The debug methods return a zero vector for any index other than 0 or 1. They report the last step's values, so they read zero when the spring is inactive.

How it behaves

A spring with Stiffness = 0 and Damping = 0 applies no force. FreeLength is the rest length; a span longer or shorter than it produces a corrective force, capped by MaxForce.

LimitsEnabled adds hard stops at MinLength and MaxLength. Stand keeps the visual coil aligned with the attachment axis, which is useful for suspension and landing gear.

CurrentLength is computed from the attachment positions and reads 0 when either attachment is missing. Active requires both attachments to be part of the same workspace.

Notes

  • Assigning a non-attachment to an attachment property is ignored.
  • Cloning copies the configuration but starts inactive.
  • The rendered coil is a gizmo line, not a solid mesh.

See also

  • RopeConstraint for a maximum-distance link.
  • Constraint for the shared attachment properties.
  • Attachment for anchor placement.

On this page