Unity 3D Playmaker Creating Flappy Birds - Game Over & Score
In this mini Unity 3D Playmaker Creating Flappy Birds tutorial, we will be setting up the Game Over & Score. In this third installation of the tutorial, we will create a quick Game Over UI, a In Game UI for displaying the Score, as well as setting up the Playmaker FSM to add to the score and trigge
This entry in the Flappy Bird mini series wires up the two things that turn a toy into a game: a game-over screen when the bird hits a pipe, and an on-screen score that ticks up every time you slip through a gap. Everything runs from one Detect Pipes FSM on the game manager, driven by the tags set up in earlier episodes.
Step 1 — Build the game-over UI
Add a new UI Panel (which brings a Canvas with it), drag the canvas under an empty UI game object, and rename it Game Over UI. Tint the panel blue and adjust its opacity so it covers the bird, then add a TextMesh Pro text that simply reads "Game Over." Turn the whole game object off — the FSM will switch it on when the moment comes.
Step 2 — Listen for pipe hits and score triggers
On the game manager, create an FSM labeled Detect Pipes. In the first state add a Trigger Event watching a specific game object — the bird — on trigger enter, with a collide tag of Pipe, sending a new event called game over. Copy that action and paste it in the same state, changing the tag to Pipe Score and the event to pipe score. One state now branches two ways: solid pipe means death, the gap's trigger zone means a point.
Step 3 — Handle game over
In the game-over state, do three things. Activate Game Object turns on the Game Over UI. A second action deactivates the bird so it disappears from the screen. Finally, use Enable FSM pointed at the pipe spawner's FSM with Enabled unchecked — that stops new pipes from generating while the game-over screen is up. Without this last step pipes keep marching across the screen behind your game-over panel.
Step 4 — Create the score display and variable
Add another canvas named In Game with a TextMesh Pro text called Score. Give it placeholder text like "xx", bold it, center it, move it to the top of the screen, and set its anchor to top center so it stays put at any resolution. Back in the Detect Pipes FSM, create an int variable named pipe score starting at zero — an int because a score is always a whole number.
Step 5 — Add to the score and push it to the UI
In the pipe score state, an Int Add action adds 1 to pipe score (no every-frame needed), then Convert Int To String turns the number into a new string variable, pipe score text — UI text only understands strings, so the conversion is mandatory. Add a finished transition back to the listening state. In that first listening state, drag the Score text object into the panel, choose Set Property, scroll to the text property, and feed it pipe score text. Because the FSM returns here after every point, the display refreshes automatically each time you score. Play it: pass a gap and the counter climbs to one, then two; clip a pipe and the pipes stop, the bird vanishes, and the game-over screen takes over.





