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(), orInstance.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.
Properties
Section titled “Properties”pivot0
Section titled “pivot0”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).
pivot1
Section titled “pivot1”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).
restLength
Section titled “restLength”Type: number · Default: 4 · Range: 0 to 10,000 (clamped) · Access: read/write · Replicates: yes
Relaxed length in studs.
stiffness
Section titled “stiffness”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).
damping
Section titled “damping”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
Methods
Section titled “Methods”Inherited from Instance: getPropertyChangedSignal, setAttribute, getAttribute, getAttributes, getAttributeChangedSignal, getChildren, getDescendants, findFirstChild, findFirstChildOfClass, findFirstChildWhichIsA, findFirstAncestor, findFirstAncestorWhichIsA, waitForChild, isA, isDescendantOf, isAncestorOf, getFullName, clearAllChildren, destroy, clone, toString
Events
Section titled “Events”Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged
Examples
Section titled “Examples”A bouncy platform
Section titled “A bouncy platform”import { Part, SpringConstraint, Vector3, getChild, workspace } from '@rally/sdk';
const base = getChild(workspace, 'PadBase', Part); // anchoredconst 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 basespring.pivot1 = new Vector3(0, -pad.size.y / 2, 0); // bottom of the padspring.parent = pad;