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

Remake Roller Splat with Unity 3D and Playmaker - PART 6 - Adding a LEVEL number to the UI

Feb 24, 2021
About this tutorial

In this Unity and Playmaker tutorial series I'll recreate Roller Splat. PART 6 - I'll be adding a LEVEL number to the UI that will continually add to the screen on every level complete. Absolutely NOCODE. Also check out How to Make a Bounce Game Series https://bit.ly/39HIYBU. ๐Ÿ‘‰๐Ÿผ To Sign up for

Written Guide

Part 6 of the Roller Splat remake fixes a small but real problem: the game keeps serving up levels, but the player has no idea how far they've gotten. This episode adds a level number to the top of the screen and bumps it every time a level is completed โ€” one int variable, one conversion, and one UI update inside the existing level manager.

Step 1 โ€” Build the level UI

Create a new canvas dedicated to the level display and call it Level Score UI. Inside it, add two TextMesh Pro texts: one holding the word LEVEL, bolded and sized up to around 70 so it reads at a glance, and a duplicate of it renamed Level Score holding the number. Give the number placeholder text of "xxx" โ€” the placeholder just reserves however many digit spaces you expect to need. Right-justify the LEVEL text and sit the number next to it so the pair reads as one label.

Step 2 โ€” Anchor it so it survives any resolution

In the Rect Transform there's a small anchor box in the upper-left corner. Set both texts to anchor to the top center of the screen. This is the difference between a UI that holds its position on every phone and one that drifts when the canvas resizes โ€” anchored to top center, the label stays in the same spot no matter what resolution the game runs at.

Step 3 โ€” Create the level variable

In the level manager FSM, open Variables and create an int named level score, starting at a value of 1 โ€” an int because a level number is always a whole number. The plan: every time the player finishes a level, add one to it.

Step 4 โ€” Convert the number and update the text

TextMesh Pro text is a string, so the int has to be converted before it can appear on screen. Add a Convert Int To String action that takes level score and writes it into a new string variable called level score UI (the name just needs to differ from the int's). Then drag the Level Score text object from the hierarchy straight into the state โ€” Playmaker asks what to do with it, so choose Set Property, scroll the long property list down to the text string, and set it to level score UI. Test it: the "xxx" placeholder should flip to 1 as soon as the game starts.

Step 5 โ€” Increment on level complete

The number never changes until something adds to it. In the existing level complete state, add an Int Add action that adds 1 to level score โ€” 1 plus 1 equals 2, and the flow already loops back through the state that resets the ball, builds the next level, and re-runs the text update. Play through a level, hit next level, and the counter reads 2; finish another and it reads 3. Small feature, but it's the first time the game actually tells the player how far they've come.

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 →