Skip to main content
โ€น Back to Tutorials
Beginner Unity

Making a Mobile Bounce Game with Unity 3D and Playmaker - Restarting After Game Over

Dec 30, 2020
About this tutorial

Beginner Game Design tutorial series creating a simple Bounce type game using Playmaker within Unity 3D. With Game Over, now I'll set up the a Restart button on the Game Over UI. Absolutely NOCODE. Also make a skateboard game playlist: https://bit.ly/34m4SHT ๐Ÿ‘‰๐Ÿผ To Sign up for email updates on my

Written Guide

The previous entry in this series ended on a dead end: the ball hits the bottom, the game over UI appears, time freezes, and the player has nowhere to go. This tutorial closes the loop by adding a restart button to that screen and wiring a Reset state that undoes everything the game over state did. No code โ€” just Playmaker actions and one UI button.

Step 1 โ€” Understand what the game over state changed Before building the reset, look at what has to be reversed. The game over state does three things: it activates the game over UI game object, it sets the enabled property on the controller's FSM to false so the player can't move, and it sets time scale to zero so the ball freezes mid-air. Reset is simply the mirror image of that list, plus one extra job the game over state never did โ€” putting the ball back where it started. Keeping this inventory in your head is what makes the reset state fast to build; you're copying actions, not inventing them.

Step 2 โ€” Add the restart button Turn the game over UI back on in the hierarchy so you can actually see what you're editing, then right-click and add a UI TextMesh Pro button. Size it at 400 by 100 so it reads clearly on a mobile-sized canvas, and give it a warmer pink fill so it stands out against the game over panel. Rename the object to something like Restart Button, then edit the child text to say Restart, bold it, switch the color to the same off-white used elsewhere in the UI, and bump the font size up. Small thing, but naming the object rather than leaving it as Button (TMP) saves confusion later when the hierarchy fills up.

Step 3 โ€” Listen for the click in the FSM With the game over state selected, drag the restart button into the state to add a UI action targeting it, choose UI, then UI Button On Click Event. That action fires an event when the player presses the button. Create a new event called Reset and assign it as the event that action sends. Playmaker will flag that the event has no transition yet โ€” add the transition and drag it out to a new state named Reset.

Step 4 โ€” Build the Reset state Copy the three actions out of the game over state โ€” Set Property, Set Time Scale, and Activate Game Object โ€” and paste them into Reset, then invert each one. Deactivate the game over UI, set the controller FSM's enabled property back to true, and set time scale back to 1. Then add a Set Position action to move the ball home. Point it at a specific game object, drag the ball in, uncheck the per-axis variable checkboxes so you can hard-code the values, and enter 0, 5.3, 0 โ€” the ball's original starting position. Leave Every Frame unchecked; this only needs to happen once.

Step 5 โ€” Return to bottom detection The reset state finishes and then has to hand control back. Add a Finished transition on Reset and wire it to the bottom detection state, which is where the FSM sits during normal play. Rearranging the states on the canvas at this point is worth the thirty seconds โ€” the loop from detect bottom, to game over, to reset, and back becomes readable at a glance.

Play it through: hit the bottom, the game over UI spawns, press Restart, and the ball snaps back to the top with the controller live and time running again. The next tutorial adds sound.

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 →