### Spring:All Source: https://context7.com/dervexdev/advancedspring/llms.txt Convenience method to set, step, and get in one call. ```APIDOC ## Spring:All(goal, delta) ### Description Combines Set, Step, and Get into a single call. Sets the goal, advances the simulation, and returns the current position. ### Parameters - **goal** (any) - Required - The target value. - **delta** (number) - Required - The time elapsed in seconds. ### Response - **value** (any) - The updated current position of the spring. ``` -------------------------------- ### Complete Spring Animation Example Following Mouse Source: https://context7.com/dervexdev/advancedspring/llms.txt A full example demonstrating smooth, spring-based animation for a part that follows the mouse cursor. It utilizes RunService.RenderStepped for frame-by-frame updates and creates separate springs for position, scale, and color, allowing for independent animation of each property. Dependencies include AdvancedSpring, RunService, and Players services. ```lua local Spring = require(path.to.AdvancedSpring) local RunService = game:GetService("RunService") local Players = game:GetService("Players") local player = Players.LocalPlayer local mouse = player:GetMouse() local part = workspace.FollowerPart -- Create springs with bouncy settings local positionSpring = Spring.new(Vector3.new(0, 5, 0), 0.6, 4) local scaleSpring = Spring.new(Vector3.new(1, 1, 1), 0.8, 6) local colorSpring = Spring.new(Color3.new(1, 1, 1), 0.9, 3) -- Animate the part every frame RunService.RenderStepped:Connect(function(delta) -- Get mouse position in 3D space local targetPos = mouse.Hit and mouse.Hit.Position + Vector3.new(0, 2, 0) or Vector3.new(0, 5, 0) -- Update springs positionSpring:Set(targetPos) positionSpring:Step(delta) scaleSpring:Set(Vector3.new(1.2, 1.2, 1.2)) scaleSpring:Step(delta) colorSpring:Set(Color3.new(0.3, 0.7, 1)) colorSpring:Step(delta) -- Apply to part part.Position = positionSpring:Get() part.Size = scaleSpring:Get() part.Color = colorSpring:Get() end) ``` -------------------------------- ### Spring:Get Source: https://context7.com/dervexdev/advancedspring/llms.txt Retrieves the current interpolated value of the spring. ```APIDOC ## Spring:Get() ### Description Returns the current position of the spring after simulation. The returned value matches the spring's initial datatype. ### Response - **value** (any) - The current interpolated value of the spring. ``` -------------------------------- ### Initialize Spring Instances Source: https://context7.com/dervexdev/advancedspring/llms.txt Demonstrates how to create new spring instances for various Roblox datatypes. Each spring is configured with initial values, damping ratios, and oscillation frequencies. ```lua local Spring = require(path.to.AdvancedSpring) -- Create a Vector3 spring with default settings (damping=1, frequency=3) local positionSpring = Spring.new(Vector3.new(0, 0, 0)) -- Create a Color3 spring with custom damping and frequency local colorSpring = Spring.new(Color3.new(1, 1, 1), 0.8, 5) -- Create a number spring for UI transparency local transparencySpring = Spring.new(0, 1, 4) -- Create a UDim2 spring for UI positioning local uiSpring = Spring.new(UDim2.new(0, 0, 0, 0), 0.9, 6) -- Create a boolean spring (interpolates between 0 and 1, returns true when >= 0.5) local toggleSpring = Spring.new(false, 1, 3) ``` -------------------------------- ### Spring.new Source: https://context7.com/dervexdev/advancedspring/llms.txt Initializes a new spring instance with specific physics properties. ```APIDOC ## Spring.new(position, damping, frequency) ### Description Creates a new spring instance with an optional initial position and physics settings. The position parameter determines the datatype of the spring. ### Parameters - **position** (any) - Required - The initial value/datatype of the spring. - **damping** (number) - Optional - Controls oscillation decay (1 = critically damped). - **frequency** (number) - Optional - Controls oscillation speed in cycles per second. ### Request Example Spring.new(Vector3.new(0, 0, 0), 1, 3) ``` -------------------------------- ### Initialize and Update Spring Instances in Luau Source: https://github.com/dervexdev/advancedspring/blob/main/README.md Demonstrates how to instantiate a new spring object, set targets, and update the spring state using the Step or All methods. This API is designed for frame-by-frame updates in a game loop. ```lua local Spring = require(path.to.this.module) -- Creates new spring class with optional initial position and settings local spring = Spring.new(Vector3.new()) -- Sets new spring goal spring:Set(Vector3.new(4, 2, 0)) -- Updates spring by delta seconds spring:Step(delta) -- Returns current spring position part.Position = spring:Get() -- Sets new goal, updates spring and returns current position part.Position = spring:All(Vector3.new(4, 2, 0), delta) ``` -------------------------------- ### Perform Combined Spring Update Source: https://context7.com/dervexdev/advancedspring/llms.txt Uses the All method to set a goal, step the simulation, and retrieve the current value in a single operation. This is ideal for concise per-frame updates. ```lua local Spring = require(path.to.AdvancedSpring) local RunService = game:GetService("RunService") local positionSpring = Spring.new(Vector3.new(0, 0, 0)) local colorSpring = Spring.new(Color3.new(1, 1, 1), 0.8, 5) local part = workspace.Part local targetPosition = Vector3.new(10, 5, 0) local targetColor = Color3.new(0.2, 0.8, 0.3) -- Simple one-liner animation loop RunService.RenderStepped:Connect(function(delta) part.Position = positionSpring:All(targetPosition, delta) part.Color = colorSpring:All(targetColor, delta) end) ``` -------------------------------- ### Spring:Step Source: https://context7.com/dervexdev/advancedspring/llms.txt Advances the physics simulation by a delta time. ```APIDOC ## Spring:Step(delta) ### Description Updates the spring simulation by the specified delta time in seconds. Should be called every frame. ### Parameters - **delta** (number) - Required - The time elapsed since the last frame in seconds. ### Request Example spring:Step(0.016) ``` -------------------------------- ### Configure Default Advanced Spring Settings Globally Source: https://context7.com/dervexdev/advancedspring/llms.txt Set project-wide default values for damping, frequency, and initial position by creating a 'config' ModuleScript in ReplicatedStorage. This allows springs to inherit these defaults unless overridden on a per-instance basis. Dependencies include the AdvancedSpring module. ```lua -- ReplicatedStorage/config.lua return { AdvancedSpring = { damping = 0.9, -- Default damping ratio frequency = 4, -- Default frequency position = 0 -- Default initial position (for number springs) } } -- Usage in your code - springs will use config defaults local Spring = require(path.to.AdvancedSpring) -- This spring will use damping=0.9 and frequency=4 from config local spring = Spring.new(Vector3.new(0, 0, 0)) -- You can still override per-instance local customSpring = Spring.new(Vector3.new(0, 0, 0), 1.2, 6) ``` -------------------------------- ### Spring:Set Source: https://context7.com/dervexdev/advancedspring/llms.txt Updates the target goal for the spring simulation. ```APIDOC ## Spring:Set(goal) ### Description Sets a new target goal for the spring to move toward. The goal must match the spring's initial datatype. ### Parameters - **goal** (any) - Required - The target value for the spring to interpolate towards. ### Request Example spring:Set(Vector3.new(10, 5, 0)) ``` -------------------------------- ### Advanced Spring Module API Source: https://github.com/dervexdev/advancedspring/blob/main/README.md This section outlines the core functions and methods available in the Advanced Spring module for creating and manipulating springs. ```APIDOC ## Advanced Spring Module API ### Description This module provides functionality to create and manage spring animations for various Roblox & Luau datatypes. It supports initial position, damping ratio, and frequency configuration. ### Methods #### `Spring.new(initialPosition, config)` - **Description**: Creates a new spring instance. - **Parameters**: - `initialPosition` (datatype) - Optional - The starting value for the spring. - `config` (table) - Optional - A table containing settings like `dampingRatio` and `frequency`. #### `spring:Set(goal)` - **Description**: Sets a new goal for the spring animation. - **Parameters**: - `goal` (datatype) - Required - The target value for the spring. #### `spring:Step(delta)` - **Description**: Updates the spring's internal state by a given time delta. - **Parameters**: - `delta` (number) - Required - The time elapsed since the last step. #### `spring:Get()` - **Description**: Returns the current position (value) of the spring. - **Returns**: - (datatype) - The current value of the spring. #### `spring:All(goal, delta)` - **Description**: Sets a new goal, updates the spring by delta, and returns the current position in one call. - **Parameters**: - `goal` (datatype) - Required - The target value for the spring. - `delta` (number) - Required - The time elapsed since the last step. - **Returns**: - (datatype) - The current value of the spring after the update. ### Supported Datatypes - `boolean`, `number`, `BrickColor`, `CFrame` (position only), `Color3`, `ColorSequence` (first and last keypoints only), `NumberRange`, `NumberSequence` (first and last keypoints only), `Rect`, `UDim`, `UDim2`, `Vector2`, `Vector3`. ### Configuration Options - `initialPosition`: Sets the starting value of the spring. - `dampingRatio`: Controls the damping of the spring oscillation. - `frequency`: Controls the speed of the spring oscillation. These settings can be configured during initialization or by modifying `DEFAULT_SETTINGS`. ``` -------------------------------- ### Set Spring Target Goals Source: https://context7.com/dervexdev/advancedspring/llms.txt Updates the target goal for an existing spring instance. The spring will automatically interpolate from its current state toward the new goal based on its physics properties. ```lua local Spring = require(path.to.AdvancedSpring) local spring = Spring.new(Vector3.new(0, 0, 0)) -- Set the spring to move toward a new position spring:Set(Vector3.new(10, 5, 0)) -- For Color3 springs local colorSpring = Spring.new(Color3.new(1, 1, 1)) colorSpring:Set(Color3.new(0.2, 0.5, 1)) -- Transition to blue -- For UDim2 springs (UI animation) local uiSpring = Spring.new(UDim2.new(0, 0, 0, 0)) uiSpring:Set(UDim2.new(0.5, 0, 0.5, 0)) -- Move to center ``` -------------------------------- ### Update Spring Simulation Source: https://context7.com/dervexdev/advancedspring/llms.txt Updates the spring physics simulation using delta time. This is typically called within a render loop to advance the spring's position. ```lua local Spring = require(path.to.AdvancedSpring) local RunService = game:GetService("RunService") local spring = Spring.new(Vector3.new(0, 0, 0)) local part = workspace.Part spring:Set(Vector3.new(10, 5, 0)) -- Update spring every frame RunService.RenderStepped:Connect(function(delta) spring:Step(delta) part.Position = spring:Get() end) ``` -------------------------------- ### Retrieve Current Spring Value Source: https://context7.com/dervexdev/advancedspring/llms.txt Fetches the current interpolated value of the spring after the simulation step. This value is used to update game object properties. ```lua local Spring = require(path.to.AdvancedSpring) local spring = Spring.new(Color3.new(1, 1, 1), 0.7, 4) spring:Set(Color3.new(0, 0.5, 1)) -- After calling Step(), get the current interpolated color spring:Step(0.016) -- ~60 FPS frame time local currentColor = spring:Get() part.Color = currentColor -- For number springs local numSpring = Spring.new(0) numSpring:Set(1) numSpring:Step(0.016) local currentValue = numSpring:Get() -- Returns interpolated number ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.