Skip to content

DampedSpringParameters

github-actions[bot] edited this page Sep 24, 2026 · 5 revisions

DampedSpringParameters

Inherits: Resource

Tuning (response time and damping) for a damped spring, shared by DampedSpring, DampedSpring2D, and DampedSpring3D.

Description

A Resource holding how quickly a damped spring responds (time) and whether it overshoots, settles cleanly, or lags behind (damping). It doesn't hold any spring state itself. That state lives on DampedSpring, DampedSpring2D, or DampedSpring3D, which read a DampedSpringParameters resource every time their update() method is called.

Because it's a plain, stateless Resource, one DampedSpringParameters can be shared by many spring instances that should all move with the same feel -- for example, every draggable UI element in a menu using the same "snappy" tuning.

Tutorials

Properties

Type Name Default Description
float damping 0.0 How overdamped or underdamped the spring is, clamped to the range [-0.9, 0.9]. 0.0 is critically damped: the fastest response that doesn't overshoot the target. Positive values are increasingly overdamped, which gives a sluggish feeling (good for camera movement). Negative values are increasingly underdamped: the spring oscillates and overshoots its target, good for things like drone following.
float damping_constant 8.0 Read-only. The c coefficient (mass = 1) derived from time and damping by setup, for the formula F = -k*(value - target) - c*velocity. Recomputed automatically whenever time or damping changes; exposed so it can be read directly, e.g. to pass into update_constants or blend it by hand.
float spring_constant 16.0 Read-only. The k coefficient (mass = 1) derived from time and damping by setup, for the formula F = -k*(value - target) - c*velocity. Recomputed automatically whenever time or damping changes; exposed so it can be read directly, e.g. to pass into update_constants or blend it by hand.
float time 1.0 How long the spring takes to respond, in seconds. Its precise meaning depends on damping: for a critically damped or overdamped spring (damping >= 0.0), it's an approximate duration for the spring to settle near its target; for an underdamped spring (damping < 0.0), it's the time until the spring reaches its first peak overshoot. Clamped to a small positive minimum.

Methods

void setup(float p_time, float p_damping)

Sets time and damping together and recomputes the spring's internal coefficients once. Prefer this over setting time and damping separately when changing both, since each of those setters also triggers its own recomputation.

Clone this wiki locally