We use cookies on this site to enhance your user experience

A SpringConstraint applies a force to its Attachment based on spring and damper behavior. Assuming the SpringConstraint has SpringConstraint/Stiffness, it will apply forces based on how far apart the Attachments are. If the Attachments are further apart than the SpringConstraint’s SpringConstraint/FreeLength then the Attachments will be forced together. If they are closer than the FreeLength then the Attachments will be forced apart. In addition, if SpringConstraint/Damping is set then there will be a damping component to the applied force that scales with the velocity of the attachments.

The following code shows how the force of a SpringConstraint is calculated:

length = constraint.CurrentLength
if constraint.LimitsEnabled then
length = clamp(constraint.CurrentLength, constraint.MinLength, constraint.MaxLength) – Constrain the length between the Min/Max length.
end
axis = (Attachment0.Position - Attachment1.Position).unit
deltaV = Attachment0.Velocity - Attachment1.Velocity
force = -constraint.Stiffness * length - constraint.Damping * deltaV:Dot(axis)
force = clamp(force, -constraint.MaxForce, constraint.MaxForce)
force * axis will be applied to Attachment0’s part at Attachment0’s Position. -force * axis will be applied to Attachment1’s part at Attachment1’s Position.


Properties

Name Type Description
float

The number of coils visualized on the SpringConstraint. This can only be set between 0 and 8.

float

The current distance between the SpringConstant’s Attachment.

float

Damping constant for the SpringConstraint. Multiplied to the velocity of the constraint’s Attachment to reduce the spring force applied.

float

Natural resting length of the spring.

bool

Sets whether the SpringConstraint enforces a minimum and maximum length.

float

The maximum force the SpringConstraint can apply on its Attachment.

float

The maximum separation the SpringConstraint will allow if SpringConstraint/LimitsEnabled is true.

float

The minimum separation the SpringConstraint will allow if SpringConstraint/LimitsEnabled is true.

float

The visualized radius of the spring’s coils.

float

The strength of the spring. The higher this value the more force will be applied when the attachments are separated a different length than the SpringConstraint/FreeLength.

float

The visualized thickness of the spring’s coils.

Inherited from Instance , Constraint

Archivable ClassName DataCost Name Parent RobloxLocked Attachment0 Attachment1 Color Enabled Visible