Skip to main content
‹ Back to Tutorials
Intermediate Unity

Unity 3D + Playmaker - Runner Series - Stacking Donuts? Why not? Let's add stacking mechanics. P1

Aug 1, 2021
About this tutorial

In this tutorial, I'll use Unity and Playmaker to add stacking mechanics to this base game. This will be one implementation of what you can use the base game for. Also check out How to Make a Bounce Game Series https://bit.ly/39HIYBU. In this tutorial series, I am covering a base runner game, but

Written Guide

Part 1 of this two-parter turns the runner base game into a stacker — the genre where your character piles up collectibles while dodging things that knock them away. Here, the runner collects donuts and avoids apples, with a bouncing donut stack and clamped counting logic built entirely in ProBuilder and Playmaker.

Step 1 — Model the donut and apple

The donut is a ProBuilder torus scaled to 0.3 — deliberately oversized relative to the character so the armful of donuts reads clearly. Two materials sell it: a tan donut base, plus a pink donut icing material (switched from metallic to specular) applied only to the top faces using ProBuilder's face selection. That face-level material trick is the key takeaway — one mesh, two materials, no texturing. The enemy is a ProBuilder sphere at 0.4, reshaped slightly into an apple, with a deep red material and a small leaf.

Step 2 — Stack and animate the donuts

Inside the player, an empty named Donuts holds Donut 1 positioned in the character's arms (a little arm clipping is fine — nobody will look that closely), then duplicated into a tall stack. To make the stack bounce with the run, check the character's jogging clip first: at 24 fps it peaks at frame 4 and bottoms out at frame 8. Create a donuts animation at the same 24 fps and keyframe the whole stack up at frame 4 and down at frame 8 — then offset individual donuts slightly, exaggerating the top ones, so the stack whips like a spring instead of moving as a rigid block.

Step 3 — Tags, triggers, and prefabs

Duplicate a donut out of the player as Donut Collectible, tag it with a new collectible tag, and set its mesh collider to convex and Is Trigger. The apple gets an enemy tag and the same collider settings. Drag both into a Prefabs folder — editing the prefab later updates every copy in the game. The player needs the receiving end: a plain Box Collider (not 2D, and not a trigger — the pickups own the triggers) sized to the character, plus a Rigidbody with Use Gravity off since this character never jumps.

Step 4 — Collect and subtract

A new FSM named Collectibles on the game manager runs two Trigger Events on the player: trigger enter with the collectible tag sends collect donuts, and with the enemy tag sends subtract donuts. Create an int variable named donuts starting at 0. The collect state does an Int Add of 1 (once, not every frame); since Playmaker has no int subtract action, the subtract state simply uses Int Add with -1 — same action, negative number. Both loop back to the listener, and Playmaker's variable inspector shows the count rising and falling live as you steer into donuts and apples.

Step 5 — Clamp the count

Without limits, the count climbs forever and dips below zero. Add an Int Compare at the top of each state: in collect donuts, if the count already equals 10, skip straight to FINISHED without adding; in subtract donuts, if it's already 0 (or somehow less), skip the subtraction the same way. Testing confirms the count pins cleanly at both ends. Part 2 builds the rest of the stacker mechanics on top of this foundation.

Unity tools by Bliz Studio
Built for our own games — now on the Asset Store

Multi Tag — unlimited hierarchical tags for any GameObject. Hierarchy Pro — style your whole hierarchy with rules. Made by a Unity dev, for Unity devs.

Explore our Unity assets →