Skip to content

How to Make a Juicy Button in Unity: Squash, Punch and Bounce

A button feels juicy when it answers the press: it squashes while the pointer is down, bounces past its size when released, and settles. A spring gives you all of that from one small rule, and unlike a tween it keeps working when the player clicks again halfway through. You can write one in about twenty lines of C#, or use All In 1 Springs Toolkit, which has the springs, the punches and a ready made button.

The same blue PLAY button pressed the same way twice. On the left, Unity's default Color Tint only darkens it. On the right, a spring also squashes it while it is held, makes it bounce past its size on release and settle, through two quick taps and a long hold

What makes a button click animation feel good

Section titled “What makes a button click animation feel good”

Four reactions cover most of what players notice:

  • Squash on press. The button shrinks a little while it is held, as if pushed in.
  • Bounce on release. It springs back past its size and settles. This overshoot is the “pop”.
  • A punch on success. A quick grow and twist when the click did something: a purchase, an unlock.
  • A shake on refusal. A short shake when the click can’t be honoured: locked, not enough coins.

Unity’s Button doesn’t do any of these by itself. Its transitions tint the button, swap its sprite, or trigger Animator states, and a keyframed clip plays the same way however the player clicked.

The usual next step is a tween: scale to 1.2 and back over a fraction of a second. A tween is a fixed animation from a start value to an end value over a set time, so a second click in the middle forces a choice. Restart the tween, and the button snaps back to where the tween begins. Start a second tween on top, and the two fight over the scale or the button stops at the wrong size. A spring has no start and no end. It only knows where it is, how fast it is moving, and where it wants to be, so a new click changes the target or adds some speed, and the motion carries on from wherever the button is. Springs vs Tweens goes into the difference.

A green BUY button clicked five times, some clicks landing in the middle of the last animation. The tween on the left snaps from its biggest straight back to its normal size whenever a click restarts it there. The spring on the right carries on smoothly from wherever it is

A spring needs three numbers for each value it animates: where the value is, how fast it is moving, and where it wants to be. Every frame, the distance to the target speeds it up, damping slows it down, and the speed moves the value. This script does that for a button’s scale, driven by the pointer events Unity’s EventSystem sends:

using UnityEngine;
using UnityEngine.EventSystems;
// The juicy button guide's hand written spring: the page shows this file as it is
public class SpringButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
// The button's visuals, on a child, so the layout never fights the scale
[SerializeField] private Transform art;
[SerializeField] private float stiffness = 300f;
[SerializeField] private float damping = 12f;
[SerializeField] private float pressedScale = 0.85f;
[SerializeField] private float releaseKick = 6f;
private float scale = 1f;
private float velocity;
private float target = 1f;
public void OnPointerDown(PointerEventData eventData) => target = pressedScale;
public void OnPointerUp(PointerEventData eventData)
{
target = 1f;
// A push past the rest size, so the button overshoots and settles
velocity += releaseKick;
}
private void Update()
{
// Capped, so a slow frame can't make the spring explode
float dt = Mathf.Min(Time.deltaTime, 1f / 30f);
velocity += (target - scale) * stiffness * dt;
velocity /= 1f + damping * dt;
scale += velocity * dt;
art.localScale = new Vector3(scale, scale, 1f);
}
}

Add it to the button, and put the button’s Image and text on a child object assigned to Art. Whatever lays the button out, such as a Layout Group, works on the button’s own RectTransform and never touches the child’s scale. The scene needs an EventSystem, which Unity adds when you create the first Canvas from the GameObject menu.

Stiffness sets how hard the button is pulled toward its target, so how fast it moves. Damping sets how quickly the wobble dies out: low values bounce several times, high values settle at once. Release Kick is the extra speed added on release, which makes the bounce. This is the spring in the clips above.

That covers one number. Twisting the button means a second spring for the angle, nudging it sideways a third for its position, and each one gets its own stiffness and damping to tune, ideally while the game runs. Many buttons multiply all of that, which is what a springs library saves you.

Don’t own it yet? → Get it on the Unity Asset Store

The ready made button. The Toolkit ships AllIn1SpringsToolkitSimpleButton, a Selectable you use instead of Unity’s Button, with a Transform Spring Component driving its art. Under the pointer it springs to its Highlighted Scale and Highlighted Rotation, and a click adds Pressed Scale Velocity Add and Pressed Rotation Velocity Add and invokes its own On Click Event. Submit from a keyboard or gamepad plays the same click. The demo’s SpringsToolkitSimpleButton prefab has it set up: it grows to 1.2 and leans 2 degrees under the pointer, and wobbles when clicked.

Your own button. Add a Transform Spring Component to the button, set its Follower to the art child and Space Type to Local Space, and turn on the Scale spring, plus Rotation if it should twist. Then call it from your pointer handlers instead of running the maths yourself:

spring.SetTargetScale(0.85f); // pointer down
spring.SetTargetScale(1f); // pointer up
spring.AddVelocityScale(Vector3.one * 6f); // the bounce on release

The spring’s Force and Drag play the parts of stiffness and damping, and you can tune them in the Inspector while the game runs. Transform Spring Component Breakdown walks through every setting, and Spring Components lists the other kinds, such as the Anchored Position Spring for UI positions and the Color Spring for tints.

Punches and shakes. The common nudges are extension methods on the component, so each reaction is one line:

spring.PunchScale(4f); // on success
spring.PunchRotation(1.5f);
StartCoroutine(spring.ShakePosition(700f, 0.35f)); // on refusal

On a Canvas, positions are in canvas units, about a pixel each, so a UI shake needs a magnitude in the hundreds where a 3D object needs single digits. Nudges and Punches lists them all, and the API page has every method on a spring.

Three buttons. PLAY is the Toolkit's demo button: it grows under the pointer and wobbles on each click. BUY grows and twists with PunchScale and PunchRotation. LOCKED shakes with ShakePosition

If something should happen when the button settles, such as enabling the next screen, a spring can tell you when it reaches its target instead of you checking every frame: see Spring Events.

UI Toolkit elements have no Transform, so a Transform Spring can’t drive them directly. The Toolkit includes a proof of concept, UiToolkitSpring.unitypackage in its Scripts folder. VisualElementProvider goes on the UIDocument’s GameObject and finds elements by name. UiToolkitSpringComponent creates a child GameObject with a Transform Spring Component on it, and copies that object’s position, rotation and scale onto the element every frame. You reach the spring through its transformSpringComponent field and call the same methods as above from the callbacks you register on the element. UI Toolkit has the setup.

By hand, the spring script above works the same way: write the value to the element’s style.scale instead of a Transform.

  • Springs don’t listen to the pointer. Apart from the Simple Button, nothing in the Toolkit reacts to hovering or clicking by itself. Your code, or a UnityEvent, calls the spring.
  • The Simple Button doesn’t extend Unity’s Button. It is its own Selectable with its own On Click Event, so listeners wired to a Button’s On Click have to be moved over.
  • No UI Toolkit button. UI Toolkit support is the proof of concept above, imported separately.
  • A spring on the position of a button inside a Layout Group fights the layout, which sets that position whenever it rebuilds. Put the motion on a child, as above.