Skip to content

SpringConstraint

A spring between two parts that pulls or pushes them toward a rest length apart: bounce pads and suspension.

  • Inherits: Constraint → Instance
  • Creatable: Yes: new SpringConstraint(), or Instance.new('SpringConstraint', parent).
  • Replication: Replicated: clients get a copy, and changes the server makes reach them.

stiffness is force per stud of stretch, so heavy parts need stiffer springs (a part’s mass is getMass(), its volume times its density); damping makes the spring settle instead of bouncing forever. The two parts still collide with each other.

Type: Vector3 · Default: new Vector3(0, 0, 0) · Access: read/write · Replicates: yes

Where the joint attaches to part0, relative to its center (in the part’s own axes).

Type: Vector3 · Default: new Vector3(0, 0, 0) · Access: read/write · Replicates: yes

Where the joint attaches to part1, relative to its center (in the part’s own axes).

Type: number · Default: 4 · Range: 0 to 10,000 (clamped) · Access: read/write · Replicates: yes

Relaxed length in studs.

Type: number · Default: 100 · Range: 0 to 1,000,000,000 (clamped) · Access: read/write · Replicates: yes

Force per stud of stretch (heavier parts need more).

Type: number · Default: 1 · Range: 0 to 1,000,000,000 (clamped) · Access: read/write · Replicates: yes

Slows the bouncing (0 bounces forever).

Inherited from Constraint: part0, part1, enabled

Inherited from Instance: name, archivable, id, className, parent, destroyed

Inherited from Instance: getPropertyChangedSignal, setAttribute, getAttribute, getAttributes, getAttributeChangedSignal, getChildren, getDescendants, findFirstChild, findFirstChildOfClass, findFirstChildWhichIsA, findFirstAncestor, findFirstAncestorWhichIsA, waitForChild, isA, isDescendantOf, isAncestorOf, getFullName, clearAllChildren, destroy, clone, toString

Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged

import { Part, SpringConstraint, Vector3, getChild, workspace } from '@rally/sdk';
const base = getChild(workspace, 'PadBase', Part); // anchored
const pad = getChild(workspace, 'Pad', Part); // anchored = false, above the base
const spring = new SpringConstraint();
spring.part0 = base;
spring.part1 = pad;
spring.restLength = 3;
spring.stiffness = pad.getMass() * 400;
spring.damping = pad.getMass() * 4;
spring.pivot0 = new Vector3(0, base.size.y / 2, 0); // top of the base
spring.pivot1 = new Vector3(0, -pad.size.y / 2, 0); // bottom of the pad
spring.parent = pad;