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\SpringsAPIOne naming rule
Section titled “One naming rule”There is no per-component API to memorise. Every method is built the same way:
Verb + What + SpringNameA 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.
| Component | Spring names | Value type |
|---|---|---|
TransformSpringComponent | Position, Scale, Rotation | Vector3, Vector3, Quaternion |
RigidbodySpringComponent | Position, Rotation | Vector3, Quaternion |
AudioSourceSpringComponent | Volume, Pitch | float |
RotationSpringComponent | none | Quaternion |
AnchoredPositionSpringComponent | none | Vector2 |
ColorSpringComponent | none | Color |
UiSliderSpringComponent | none | float |
LightIntensitySpringComponent | none | float |
CamFovOrSizeSpringComponent | none | float |
ShaderFloatSpringComponent | none | float |
FloatSpringComponent | none | float |
Vector2SpringComponent | none | Vector2 |
Vector3SpringComponent | none | Vector3 |
Vector4SpringComponent | none | Vector4 |
So AddVelocity on a Vector3SpringComponent, AddVelocityPitch on an AudioSourceSpringComponent, AddVelocityScale on a TransformSpringComponent. Same method, three names.
The methods
Section titled “The methods”T below is the component’s value type from the table above. Append the spring name where the component has one.
Value and motion
Section titled “Value and motion”| Method | What 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 |
Force and drag
Section titled “Force and drag”| Method | What 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 |
Clamping
Section titled “Clamping”| Method | What 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.
Events
Section titled “Events”Each spring exposes a SpringEvents through a property, named the same way: Events, or PositionEvents, ScaleEvents, RotationEvents, VolumeEvents, PitchEvents. See Spring Events.
Convenience overloads
Section titled “Convenience overloads”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.
Where rotation is different
Section titled “Where rotation is different”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.
Per component extras
Section titled “Per component extras”Beyond the standard set:
| Component | Extra |
|---|---|
TransformSpringComponent | followerTransform, targetTransform, useTransformAsTarget, spaceType, SpringPositionEnabled, SpringRotationEnabled, SpringScaleEnabled, UpdateTarget() |
RigidbodySpringComponent | useTransformAsTarget, and PositionSpring / RotationSpring to reach the springs directly |
AudioSourceSpringComponent | VolumeSpring, PitchSpring |
ColorSpringComponent | SetAutoUpdateToTrue(bool isRenderer, GameObject target), SetAutoUpdateToFalse() |
CamFovOrSizeSpringComponent | GetAutoUpdatedCamera(), SetAutoUpdatedCamera(Camera) |
LightIntensitySpringComponent | UpdateLightIntensity() |
On every component
Section titled “On every component”Inherited from SpringComponent:
| Member | What 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 |
doesAutoInitialize | Initialize on Awake, or leave it to you |
useScaledTime | Use 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 |
alwaysUseAnalyticalSolution | Force the stable integrator for this component. See Asset Window |
Reaching the spring underneath
Section titled “Reaching the spring underneath”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.
Also worth knowing
Section titled “Also worth knowing”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.
