Preview
What is it?
- A simple, strictly typed spring module that supports number, vector2 and vector3 values. I made this because other spring modules that i have found either didnt have the properties i wanted or had way too much properties that over complicated things or had way too many methods along side other things. Thought i would share this incase anyone finds it useful.
Properties
- Mass - Self explanatory. Higher mass → slower response.
- Stiffness - How strongly the spring pulls towards the target. Higher stiffness → faster correction.
- Damper - How much energy gets removed. Low damper → bouncy, High damper → no bounce.
- Speed - Time scale / multiplier.
States
- Target - The goal value that the spring is trying to reach.
- Position - The current solved value of the spring.
- Velocity - How fast the spring is currently moving.
Methods
- Impulse(Velocity) - Applies a impulse of velocity to the spring.
- Destroy() - Destroys the spring.
Example
-- Modules
local Springs = require("Path-To-Module")
-- New spring
local spring = Springs.new(0)
spring.Mass = 1.5
spring.Damper = 9
spring.Stiffness = 150
spring.Speed = 1
-- Apply a impulse of velocity to the spring
spring:Impulse(85)
-- Remove the spring
task.wait(5)
spring:Destroy()
Resources
Get the model here: https://create.roblox.com/store/asset/111078913537568/Spring-Module
Download the example button as seen in the preview: exampleButton.rbxm (11.3 KB)