Remake Roller Splat with Unity 3D and Playmaker - Setting up to Detect if a Level is Complete
In this Unity and Playmaker tutorial series I'll recreate Roller Splat. PART 4 - In this tutorial I'll set up detecting if the level is complete and triggering a Level Complete UI. Absolutely NOCODE. Also check out How to Make a Bounce Game Series https://bit.ly/39HIYBU. ๐๐ผ To Sign up for email
A Roller Splat clone needs to know when a level is finished, which means counting how many floor tiles exist and how many have been painted, then comparing the two. This part sets up global variables for those counts, an FSM that resets and compares them, a per-tile increment, and a Level Complete UI that triggers when the numbers match.
Count tiles and create global variables
First, count the paintable tiles in the level; in this example there are 20. Open Playmaker and create a global variable as an int (whole number) called Level Tile Count for how many tiles the level has. Add a second int global called Level Tile Hit for how many tiles have been painted so far. Globals are used here so any FSM can read and update these shared counts.
Set up the level FSM and reset the counts
Add an FSM to the level itself. In the start state, named Level Setup, use Set Int Value to set Level Tile Count to 20 and Level Tile Hit to 0, so each playthrough begins with a fresh target and a zero count. Add a Finished transition to a new state called Compare Tile Count.
Compare the counts every frame
In Compare Tile Count, add an Int Compare action and uncheck the variable boxes so you can plug in the globals: compare Level Tile Count against Level Tile Hit. When they are equal, send a new Level Complete event and add the transition to a Level Complete state. Set this action to run every frame so the level constantly checks whether it's finished.
Increment the count on each tile hit
Initially the tiles change color but never raise the count. Open the floor tile prefab's FSM, find the Tile Was Hit state, and add an Int Add action that adds 1 to the global Level Tile Hit. Leave it off Every Frame so it only increments once per tile when that tile is first painted.
Build and trigger the Level Complete UI
Create a UI canvas named UI Level Complete (and an empty UI parent object for organization). Add a Panel colored a warm orange-yellow with raised opacity, plus a TextMesh Pro text reading LEVEL COMPLETE, bold, centered, around 90 pixels, with the box widened to span the screen so it stays centered. Turn it off. In the Level Complete state, add an Activate Game Object action targeting the UI Level Complete object (lock the FSM and specify the object rather than the owner). Testing it, the tile-hit count climbs as the ball paints tiles, and when it reaches 20 the Level Complete UI appears.





