Unity + Playmaker - Countdown Timer and Flight Time
Unity + Playmaker - Countdown Timer and Flight Time - This is part 5 of a recording of my mini game jamI am using Playmaker to create a countdown sequence and also establishing flight time based on the number of clicks the user is able to click within the 5 second button "fueling" time. There are
Part five of this rocket-launch mini game jam adds two things: a five-second countdown that holds players off the launch button until they're ready, then converts how fast they tap into the rocket's flight time. The faster you mash the button, the longer the rocket stays in the air, with the click count flowing through a chain of math into the launch animation length.
Build the countdown text animation
Add a TextMeshPro UI object centered in the button, bold, around 28pt, starting at 5. Create a one-frame-per-second animation (no Animator components nested inside — Unity won't allow an animator within an animator), and on each keyframe toggle child objects so 5, then 4, 3, 2, 1 appear in turn, switching the previous number off as the next turns on. Turn off looping so it plays once and stops.
Gate the button behind a five-second wait
In the Game Manager, add a Start state with a Wait of 5 seconds that finishes into the click-counter state. During the wait, fade the fuel button and timer down so they read as disabled, then at the start of the counter state use Set Color (UI image, white, full opacity) on both to snap them back to fully visible. Make click counter a global event so the rest of the system can reach it. The timer bar gets its own Wait 5 start state too, so it doesn't drain during the countdown.
Turn clicks into a launch time value
Add a separate FSM, launch time, to keep the math isolated. It reads the global int spacex count and divides it by 2 with an Int Operator, storing the result in a new global int launch time — so 30 taps becomes a 15-unit flight rather than an overly long 30. Run this once on demand, not every frame: trigger it with a global transition fired by a Send Event By Name when the launch begins.
Display the value on screen
To verify the math while building, add a TextMeshPro field and convert launch time with Int To String into launch time text, then push that into the field with Set Property on the text component. Initialize it to zero in the click-count state so it reads cleanly from the start. A common gotcha here: make sure you convert and display the actual global launch time, not a stale local copy, or the number never updates.
Feed flight time into the animation length
The launch and descent animations should last as long as the computed flight time. Since animation time is a float and launch time is an int, add Int To Float to produce a new global float launch anim time. In the click-count sequence, use that float to set the animation length for both the rise and fall, so a few taps give a short hop and heavy mashing gives a long flight. Remove any leftover fixed Wait at the end of the descent so the rocket transitions back to landing the moment its animation finishes.





