Skip to content

Spring Types

Underneath every Spring Component sits one of six spring types. They are plain C# classes, not MonoBehaviours, and each one is an array of independent one-dimensional springs plus the methods to talk to them.

You meet them in two situations: when a component’s own API does not expose something you need, and when you write your own component and have to declare the springs it will run.

TypeDimensionsNotes
SpringFloat1The one everything else is built from
SpringVector22
SpringVector33Position and scale use this
SpringVector44
SpringColor4A SpringVector4 that speaks in Color and handles the conversion for you
SpringRotation9Special, see below

Each dimension is a separate spring with its own force, drag, velocity and clamping, which is why you can make a position spring that is stiff on Y and loose on X.

Rotation cannot be sprung by treating a quaternion as four numbers, so this type does something else: an axis-angle representation plus extra dimensions that keep track of overshoot past 180 degrees in the same direction, added velocity, and a few other cases. Nine dimensions in total, not all in play at once.

The implementation is the least obvious thing in the asset, and you do not need to understand it. It answers to the same methods as every other spring. Two differences are worth knowing. Rotation springs have no clamping and no per-axis force or drag, they take a single unified force and drag and that is it. And they have an Axis Restriction setting in the Inspector, which locks the spring to X, Y or Z only, which is what you want for a wheel, a lever or anything in a 2D game.

Every type answers to the same family of methods:

SpringVector3 spring = new SpringVector3();
spring.SetCurrentValue(transform.position); // where it is
spring.SetTarget(destination); // where it is going
spring.AddVelocity(Vector3.up * 8f); // shove it
spring.SetUnifiedForce(200f); // one force for all axes
spring.SetUnifiedDrag(12f);
spring.SetForce(new Vector3(200f, 60f, 200f)); // or one per axis
spring.SetMinValues(Vector3.zero); // clamping bounds
spring.SetMaxValues(Vector3.one * 10f);
spring.SetClampCurrentValues(true, true, true);
spring.StopSpringOnClamp(true, true, true);

StopSpringOnClamp is the one that is easy to miss. With it on, a spring that hits a bound stops there instead of pressing against it, and the OnClampingApplied event fires so you can react. It is how you build something that falls, lands, and stays landed.

The full method list, per component, is on the API reference.