Unity Game Dev Guide: Update UI Slider - Playmaker Tutorial
In this Unity tutorial, learn how to use Playmaker to create fluid, real-time player UI sliders for health, fuel, mana, or any other attributes. We'll go over how to dynamically connect Playmaker variables to control Unity UI sliders, allowing them to update as player stats change during gameplay. T
This tutorial hooks a UI slider up to a rocket fuel system: holding the mouse fires the jetpack and drains fuel, running dry forces the rocket off, and idling slowly refills the tank. The same pattern works for health, mana, or any depleting resource — the slider is just a visual window onto one float variable.
The starting point
The player already has a two-state FSM: rocket off and rocket on. Mouse button down transitions to rocket on, which activates the jetpack animation object, enables a looping rocket audio source, and applies force on Y through the Rigidbody 2D; releasing the mouse returns to idle and gravity pulls the player down. The slider is a UI Slider on a canvas named UI HUD, handle deleted, rotated 90 degrees on Z to stand vertical. Its value is normalized 0 to 1 — zero to one hundred percent.
Drain fuel while flying
Create a float variable rocket fuel with an initial value of 1 — a full tank. In the rocket on state, add Float Subtract: take 0.01 (one percent) off rocket fuel every frame. Then add Slider Set Value; Playmaker complains the owner has no slider component, so switch to specify game object, drag the slider in, check use variable, and point it at rocket fuel. The bar now falls in lockstep with the tank.
Cut the engine at empty
Add a Float Compare checking rocket fuel against 0 with zero tolerance, every frame: on equal or less than, transition to rocket off. Test it — the UI drains as you fly, and at empty the thrust dies. You can mash the button all you want; the compare keeps kicking you back to rocket off. Effective, but permanently stranding the player is torture, so give the fuel back.
Refill while idle
You could gate refueling behind pickups, but here the idle state regenerates it. Copy the Slider Set Value action into rocket off, then add a Float Add on rocket fuel of 0.001 per frame — a tenth of the drain rate, which forces the player to choose when the boost is worth spending. One bug remains: adding every frame lets fuel climb past 1, beyond a full tank. Fix it with a Float Clamp at the end of the action stack, capping rocket fuel at a max of 1. Test the loop: burn the tank, drop to idle, watch the bar creep back up. Tune the subtract, add, and force numbers until the risk-reward feels right for your game.





