Nudges and Punches (Free Game Polish!)
The term “nudge” refers to pushing a spring to trigger a reaction from it. As we learned earlier, springs don’t have a fixed state; we can alter the Current Value or Velocity at any time, and the spring will react and adapt to the change without issues. This ability to nudge the springs gives us the opportunity to add a lot of polish and liveliness to our projects with just a single line of code.
Punches and shakes on a UI button, with a spring button written by hand to compare: How to Make a Juicy Button in Unity.
Two ways to nudge a spring
Section titled “Two ways to nudge a spring”We typically consider two different ways of nudging or punching (we’ll use these terms interchangeably):
- SetCurrentValue: By instantly changing the Current Value using the SetCurrentValue method, we can ensure that the Target is different from the Current Value, thereby guaranteeing that an animation will occur. There are some examples of this in the Demo. For instance, in an action game where characters can get hit, we could set the current value of the object’s scale on the frame it’s hit, causing the object to grow and then animate back to its resting state.
- AddVelocity: Similarly, using the AddVelocity method will cause the spring to move. If the spring is at rest with a velocity of 0, it will animate out of the resting state and eventually return to rest. If the velocity was non-zero, it will still influence and nudge the spring in a satisfying way.

Ready-made punches and shakes
Section titled “Ready-made punches and shakes”You rarely need to write those calls by hand. The toolkit ships the common punches as extension methods, so they appear on the component itself with no setup and no extra reference:
transformSpringComponent.PunchScale(0.5f);transformSpringComponent.PunchPositionVertical(3f);StartCoroutine(transformSpringComponent.ShakeRotation(magnitude: 20f, duration: 0.4f));On TransformSpringComponent
Section titled “On TransformSpringComponent”
| Method | What it does |
|---|---|
PunchScale(baseScale, multiplier = 1) | A uniform scale punch. The classic “it got hit” pop |
ApplyScaleHit(config, multiplier = 1) | A uniform scale punch with its own Force and Drag. See Hits with their own Force and Drag |
RandomPunchScale(magnitude) | A scale punch in a random X/Y direction, so repeats don’t look identical |
ScaleUpFromZero(targetScale = 1) | Makes the object spring into view, growing from zero to targetScale. Also takes a Vector3. Any velocity left from an earlier punch is cleared first, so it doesn’t carry into the entrance |
ShakeScale(magnitude, duration, frequency = 40) | Keeps punching the scale for a duration. A coroutine, start it with StartCoroutine |
PunchRotation(baseRotation, multiplier = 1, randomDirection = true) | A twist around Z. Clears the existing rotation velocity first, so rapid repeats stay controlled. With randomDirection off it twists in the direction of the sign you pass |
ApplyRotationHit(config, multiplier = 1, randomDirection = false) | A twist around Z with its own Force and Drag |
RandomPunchRotation(magnitude) | The same twist, with a random sign |
ShakeRotation(magnitude, duration, frequency = 40) | Alternating twists for a duration. Coroutine |
PunchPosition(direction, magnitude) | A shove along any direction you pass |
ApplyPositionHit(config, direction, multiplier = 1) | A shove along any direction, with its own Force and Drag |
PunchPositionVertical(magnitude) | A shove straight up |
PunchPositionHorizontal(magnitude) | A shove to the right |
RandomPunchPosition(magnitude) | A shove in a random direction. Returns the direction it picked, in case you want to match a particle or a sound to it |
ShakePosition(magnitude, duration, frequency = 40) | Positional shake for a duration. Coroutine |
On AnchoredPositionSpringComponent
Section titled “On AnchoredPositionSpringComponent”The UI equivalent, working in anchored position:
| Method | What it does |
|---|---|
PunchPosition(direction, magnitude) | A shove along any direction |
ApplyHit(config, direction, multiplier = 1) | A shove along any direction, with its own Force and Drag |
PunchVertical(magnitude) | A shove up |
PunchHorizontal(magnitude) | A shove right |
RandomPunch(magnitude) | A shove in a random direction |
Shake(magnitude, duration, frequency = 40) | Shake for a duration. Coroutine |
The three shake methods are coroutines because they punch repeatedly over time: roughly duration * frequency punches, each one in a direction chosen to oppose the last so the motion reads as a shake rather than a drift. They zero the velocity when they finish. They follow the component’s Use Scaled Time option, so with it off they keep shaking in a paused menu.
None of these do anything the component’s own methods can’t. They are the calls you would have written yourself, already written and named.
Hits with their own Force and Drag
Section titled “Hits with their own Force and Drag”A punch moves with whatever Force and Drag the spring already has. Sometimes one spring needs a different feel depending on what hit it: a light pop when the pointer hovers, a hard slam when the player is refused. The Apply…Hit methods take a SpringHitConfig, which bundles the three numbers a hit needs:
[SerializeField] private SpringHitConfig hoverHit = new SpringHitConfig(impulse: 6f, force: 1500f, drag: 25f);[SerializeField] private SpringHitConfig refuseHit = new SpringHitConfig(impulse: -15f, force: 700f, drag: 12f);
transformSpringComponent.ApplyScaleHit(hoverHit);transformSpringComponent.ApplyRotationHit(refuseHit, randomDirection: true);SpringHitConfig is serializable, so every hit shows up in the Inspector and can be tuned where it is used.
A hit sets the spring’s Force and Drag to the config’s values (switching it to unified Force and Drag), then adds the impulse as velocity. Those values stay on the spring after the hit, so a later punch or target change on the same spring moves with the last hit’s feel.
Like every punch, a hit adds velocity. If something can be hit several times in a row and the hits shouldn’t pile up, set the velocity to zero first:
transformSpringComponent.SetVelocityScale(0f);transformSpringComponent.ApplyScaleHit(refuseHit);The optional multiplier scales the impulse for one call, so the same config can grow with a combo count, follow the size of the damage, or flip sign to squash instead of pop.
A button that answers every press
Section titled “A button that answers every press”A small component that gives a button three different reactions from one spring: a light pop on hover, a big pop when the press goes through, and a squash with a twist when it’s refused.
using AllIn1Assets.AllIn1SpringsToolkit;using UnityEngine;using UnityEngine.EventSystems;
public class ButtonFeedback : MonoBehaviour, IPointerEnterHandler{ [SerializeField] private TransformSpringComponent spring; [SerializeField] private SpringHitConfig hoverHit = new SpringHitConfig(20f, 1500f, 25f); [SerializeField] private SpringHitConfig pressedHit = new SpringHitConfig(35f, 1500f, 25f); [SerializeField] private SpringHitConfig refusedHit = new SpringHitConfig(-15f, 1500f, 25f); [SerializeField] private SpringHitConfig refusedTwist = new SpringHitConfig(6f, 700f, 15f);
public void OnPointerEnter(PointerEventData eventData) => spring.ApplyScaleHit(hoverHit);
public void Pressed() { // A spammed button pops the same every time instead of growing spring.SetVelocityScale(0f); spring.ApplyScaleHit(pressedHit); }
public void Refused() { spring.SetVelocityScale(0f); spring.ApplyScaleHit(refusedHit); spring.ApplyRotationHit(refusedTwist, randomDirection: true); }}
Put the Transform Spring Component on a child that holds the button’s art, not on the object that receives the pointer. If the hit area itself grows and shrinks, the pointer keeps crossing its edge and the hover flickers on and off.
Springing into view
Section titled “Springing into view”ScaleUpFromZero makes an object grow into existence: the scale snaps to zero with no velocity left over, then the spring grows it back to full size. Because the velocity is cleared, a pooled object doesn’t carry a punch from its previous life into its entrance. Add a hit on top for some extra character:
[SerializeField] private SpringHitConfig spawnTwist = new SpringHitConfig(40f, 250f, 8f);
pickup.SetActive(true);pickupSpring.ScaleUpFromZero();pickupSpring.ApplyRotationHit(spawnTwist, randomDirection: true);
If the object’s resting size isn’t 1, pass it: ScaleUpFromZero(0.8f), or a Vector3 for a non uniform size.
ApplyHit does the same for an Anchored Position Spring Component. The direction is normalised, so the strength comes from the config’s impulse (in anchored position units per second) times the multiplier:
[SerializeField] private AnchoredPositionSpringComponent healthBarSpring;[SerializeField] private SpringHitConfig damageHit = new SpringHitConfig(1500f, 200f, 10f);
public void OnDamaged(float damageRatio){ healthBarSpring.SetVelocity(0f); healthBarSpring.ApplyHit(damageHit, Vector2.down, damageRatio);}Anchored position is measured in canvas pixels, so UI impulses run in the hundreds or thousands: here a hit taking a third of the health starts the bar at 500 pixels per second, which moves it about 20 pixels.

See it in the Demo
Section titled “See it in the Demo”Exploring the Demo examples is the best way to see all of these concepts in action and gain a deeper understanding of how nudges and punches can enhance the game juice of your projects.
