Make a Match-Three Puzzle Game in Unity
Note: though much of the course was recorded with an older version of Unity, the final project has been updated to use Unity 2018.3. Though there are minor differences in the UI, you should be able to complete the course using Unity 2018.
We have created over five hours of extra lectures describing how to add additional gameplay features to our match-three game! We have also re-recorded some videos and updated the projects accordingly (Unity 5.6 used for the project files). Check out these new features added:
re-skinning your game using your own Sprites
checking for the deadlock condition (no more available moves)
shuffling the Board pieces (instead of deleting them and re-filling the Board)
building a one-, two-, or three-star score meter
creating new level objectives (scored, timed, and collected)
This course now weighs in at a 15+ hour marathon in game development. Save weeks of work on building your own match three game.
Join the ever growing ranks of our class and see what you can build today!
In this course, we will:
start with a blank Unity project and flesh out a fully working game level
learn some fundamental techniques for creating your own tile-based match-three puzzle game
follow several C# scripts line-by-line and learn how to organize our scripts logically and cleanly
What is covered:
Setup our project settings and environment
Create a Board class to store our tiles and game pieces
Create an auto-centered orthographic camera
Make a GamePiece class that can move with interpolation
Setup the tiles to receive mouse input
Search for matches in a two-dimensional array
Handle recursive calls to clear and refill our Board
Add sound effects to game events
Apply particle effects to add some punch to our graphics
Making a score manager to track player progress
Join the democratization of game development! Level up your Unity 3D skills and build your own match-three game today!
When you complete the class, you should have a full set of source code as a starting point for your match-three puzzle game!
The journey of a thousand miles begins with the first step!
What you need to know first!
How to use SavePoints, compare text files, and ask for help!
In this lecture, we will create a new Unity project and discuss the various naming conventions used in our scripted components.
Basic Game Mechanics
Here we setup the game board and create the background tiles.
Let's make an orthographic camera that stays centered on our Board.
We extend the Tile component, which is the building block of our Board, in this short lecture.
The GamePiece class describes the playable components that can be moved around the Board to make the matches.
Let's create methods on the GamePiece to allow it to move around the Board.
Here we explore some basic interpolation types to make the movement seem a little more natural.
Here we add the ability to interpret our mouse clicks and drags over the game board's tiles.
Let's code the basic ability to swap a GamePiece with its neighbor.
Here we create a basic method on the Board class to detect matching pieces.
Here we make some functions that wrap around FindMatches that help us find matching pieces in the horizontal or vertical direction. We also make a simple Highlight method to help us visual the matching process.
We use the newly created FindMatchesAt method in conjunction with our SwitchTiles to test if we make a match when we swap GamePieces.
We create the ClearPieceAt method, which will be used to remove matching GamePieces from our Board.
Once we have cleared out some GamePieces, we need to collapse the columns to fill in any "holes" that form.
We need to collapse our Board recursively so we can clear out any "chain reaction" matches that form.
Let's adjust our collapse speed so that it varies according to the distance the GamePiece falls.
Now that our columns are collapsed to fill in the gaps, we modify the FillBoard method to fill in the partially empty Board.
Let's make a special Tile that acts like a hole or obstacle.
Let's make tiles that can be "broken."
We create some simple geometric particle effects to represent clearing GamePieces or breaking Tiles.
We create a ParticleManager so we can trigger our ParticleSystems on certain game conditions.
We trigger our ParticleSystems when we clear the GamePieces or break the Tiles.
We add an array of GamePieces that we can use to customize the starting configuration of our Board.
We create a generic singleton class that can be used for our manager scripts.
Who's keeping score?
Let's invoke the methods on the ScoreManager in the GamePiece, GameManager and Board classes.
Let's make a simple Image that can cover our screen and fade in and out to help with transitions.
Let's make a manager class to keep track of our game's sequence of events. Everything has a beginning, middle and end!
We can count our moves and lose the game now.
We lay out some UI elements to make a small message box.
We create two classes to control our new dialog box, the RectXformMover to move the window on and off screen and the MessageWindow class to control the text displayed.
Now we put everything together from the last two lessons and make the GameManager talk to the Message Window.
Let's trigger the message window if you win or lose the game.
We make a manager class to store and playback sounds.
Let's finish the SoundManager!
Let's tweak our game so it's more friendly for a mobile device.
Download Xcode and get your Apple Developer account setup. We need to provision our devices before we go back to Unity.
Note: this lesson does not contain a Save Point.
Download Android Studio and setup your device drivers to be debuggable via USB.
Note: this lesson does not contain a Save Point. Your individual system settings may vary depending on platform and SDK version.
Here we modify the Player Settings in Unity to accommodate the needs of our mobile platform.
We build our game for iOS!
Note: You will need to add your iOS Development Team ID from your Apple Developer account in order to Build the project from the SavePoint.
We build the game for Android!
Note: you must choose the paths to your Android SDK and Java SDK in the Unity > Preferences in order to build your project from the SavePoint.
Here is the final project with comments added in-line.
In this Update, we add a small delay before the EndGameRoutine in the main game loop to wait for the Board to finish its refill.