Transform Spring Component Breakdown
This is the component most projects use most, and the most complex one in the asset. Learn it and the others are easy, because they are all the same shape with fewer parts.
Three springs in one component
Section titled “Three springs in one component”TransformSpringComponent runs a position spring, a rotation spring and a scale spring, and applies all three to one transform.
| Spring | Type | Drives |
|---|---|---|
| Position | SpringVector3 | Where the object is |
| Rotation | SpringRotation | How it is turned |
| Scale | SpringVector3 | How big it is |
Each has its own Force, Drag, clamping and events, so a card can snap into position while it lazily rotates. Turn off the ones you do not need with SpringPositionEnabled, SpringRotationEnabled and SpringScaleEnabled, in the Inspector or from code. A disabled spring costs nothing.
Follower and target
Section titled “Follower and target”The Follower Transform is what gets moved. It defaults to the object the component sits on, and most of the time you leave it alone. Pointing it at a different transform is occasionally handy, for example to keep the component and its setup on a parent while the child does the moving.
The target comes from one of two places:
- Use Transform As Target ticked: assign a Target Transform and the component follows it every frame, no code involved. Good for cameras, followers, anything chasing something else.
- Unticked: the target is whatever you last set from a script.
spring.SetTargetPosition(door.position);spring.SetTargetRotation(new Vector3(0f, 90f, 0f)); // euler, or pass a Quaternionspring.SetTargetScale(Vector3.one * 1.5f);World or local space
Section titled “World or local space”Space Type decides whether the position and rotation springs work in world space or local space. Local is what you want for anything parented to something that moves, like UI inside a panel or a turret on a moving tank. Getting this wrong usually looks like an object fighting its parent.
Reading it back
Section titled “Reading it back”Every spring reports its state, which is how you drive other things off the motion:
if (Vector3.Distance(spring.GetCurrentValuePosition(), spring.GetTargetPosition()) < 0.01f){ // close enough, though OnTargetReached does this for you}
float speed = spring.GetVelocityPosition().magnitude;audioSource.pitch = 1f + speed * 0.05f;Punching it
Section titled “Punching it”The transform component is the one with the ready-made punch and shake helpers, since it is where most game feel lives:
spring.PunchScale(0.4f);spring.PunchPositionVertical(6f);StartCoroutine(spring.ShakeRotation(magnitude: 25f, duration: 0.3f));The full list is on Nudges and Punches, and every method the component has is on the API Reference.
