Skip to content

SpringComponent Public Methods and API

Every Spring Component ships a partial class holding its public API. This page is the reference for all of them.

The files live in:

Assets\Plugins\AllIn1Assets\AllIn1SpringsToolkit\Scripts\SpringsAPI

There is no per-component API to memorise. Every method is built the same way:

Verb + What + SpringName

A component with one spring drops the name, so FloatSpringComponent has SetTarget. A component with several springs keeps it, so TransformSpringComponent has SetTargetPosition, SetTargetScale and SetTargetRotation. Learn the verbs once and the rest follows.

ComponentSpring namesValue type
TransformSpringComponentPosition, Scale, RotationVector3, Vector3, Quaternion
RigidbodySpringComponentPosition, RotationVector3, Quaternion
AudioSourceSpringComponentVolume, Pitchfloat
RotationSpringComponentnoneQuaternion
AnchoredPositionSpringComponentnoneVector2
ColorSpringComponentnoneColor
UiSliderSpringComponentnonefloat
LightIntensitySpringComponentnonefloat
CamFovOrSizeSpringComponentnonefloat
ShaderFloatSpringComponentnonefloat
FloatSpringComponentnonefloat
Vector2SpringComponentnoneVector2
Vector3SpringComponentnoneVector3
Vector4SpringComponentnoneVector4

So AddVelocity on a Vector3SpringComponent, AddVelocityPitch on an AudioSourceSpringComponent, AddVelocityScale on a TransformSpringComponent. Same method, three names.

T below is the component’s value type from the table above. Append the spring name where the component has one.

MethodWhat it does
T GetTarget()Where the spring is heading
void SetTarget(T)Send it somewhere new. Safe to call every frame, or mid-motion
T GetCurrentValue()Where it is right now
void SetCurrentValue(T)Teleport the value. The spring animates back from wherever you put it, which is how most punches are made
T GetVelocity()Current speed
void SetVelocity(T)Overwrite the speed
void AddVelocity(T)Shove it without discarding the motion it already had
void ReachEquilibrium()Stop dead at the target. Zeroes velocity and snaps the current value
MethodWhat it does
float GetUnifiedForce(), void SetUnifiedForce(float)One force for every axis. Setting it also switches the spring into unified mode
float GetUnifiedDrag(), void SetUnifiedDrag(float)Same, for drag
void SetUnifiedForceAndDrag(float, float)Both at once
T GetForce(), void SetForce(T)Per axis, when you want X to behave differently from Y
T GetDrag(), void SetDrag(T)Per axis drag
MethodWhat it does
void SetMinValues(T), void SetMaxValues(T)The bounds
void SetClampCurrentValues(bool per axis)Clamp the value the spring produces
void SetClampTarget(bool per axis)Clamp the target instead, so the spring never aims outside the range
void StopSpringOnClamp(bool per axis)On hitting a bound, stop rather than press against it. Fires OnClampingApplied

The clamp methods take one bool per axis: one for a float spring, three for a Vector3, four for a Color.

Each spring exposes a SpringEvents through a property, named the same way: Events, or PositionEvents, ScaleEvents, RotationEvents, VolumeEvents, PitchEvents. See Spring Events.

Every vector method has a float overload that broadcasts to all axes, so SetForce(200f) on a Vector3 spring means 200 on X, Y and Z. Rotation methods accept a Quaternion or a Vector3 of euler angles, whichever you have.

Rotation springs answer to a smaller set. They have no clamping and no per-axis force or drag. SetUnifiedForce and SetUnifiedDrag are how you tune them, and SetMinValues, SetClampTarget, StopSpringOnClamp and the per-axis SetForce do not exist.

This applies to RotationSpringComponent and to the rotation half of TransformSpringComponent and RigidbodySpringComponent.

Beyond the standard set:

ComponentExtra
TransformSpringComponentfollowerTransform, targetTransform, useTransformAsTarget, spaceType, SpringPositionEnabled, SpringRotationEnabled, SpringScaleEnabled, UpdateTarget()
RigidbodySpringComponentuseTransformAsTarget, and PositionSpring / RotationSpring to reach the springs directly
AudioSourceSpringComponentVolumeSpring, PitchSpring
ColorSpringComponentSetAutoUpdateToTrue(bool isRenderer, GameObject target), SetAutoUpdateToFalse()
CamFovOrSizeSpringComponentGetAutoUpdatedCamera(), SetAutoUpdatedCamera(Camera)
LightIntensitySpringComponentUpdateLightIntensity()

Inherited from SpringComponent:

MemberWhat it does
void Initialize()Sets the component up. Called automatically unless you turned off Auto Initialize, or added the component at runtime
void ReachEquilibrium()Stops every spring on the component at once
bool IsValidSpringComponent()Whether the component has what it needs. Checked at startup and again every frame, and a component that fails disables itself
doesAutoInitializeInitialize on Awake, or leave it to you
useScaledTimeUse Time.deltaTime or Time.unscaledDeltaTime. Turn it off and springs keep running while the game is paused, which is what you want for pause menus
alwaysUseAnalyticalSolutionForce the stable integrator for this component. See Asset Window

The springs themselves are private on most components, so the API above is the whole surface. Three exceptions: RigidbodySpringComponent and AudioSourceSpringComponent expose theirs as properties, and TransformSpringComponent keeps its three protected, so a subclass can reach them.

If you need something the API does not cover, the usual answer is to write your own component around a raw spring type, which gives you the full surface with nothing hidden.

TransformSpringComponent and AnchoredPositionSpringComponent carry a set of extension methods for punches and shakes, listed on Nudges and Punches. They are not in the API files, they are in Scripts/Other, and they behave like ordinary methods on the component.