Game Toolkit for Unity
Stetting up the jewel prefabs.
In the last tutorial we’ll set up the jewel prefabs. We’ll add an Object Variables component storing the points the player gets when destroying a jewel, an Interaction Machine for playing the Jewel Click schematic and a Tagged Machine for handling the jewel’s destruction.
The setup for all jewel prefabs is the same. The following component setup can be repeated for all jewel prefabs, or you can just copy the components and paste them on the other jewels.
You can copy a component by right-clicking on the component’s name and selecting Copy Component in the context menu. To paste the component on a game object, right-click on any component’s name and select Paste Component As New in the context menu.
The jewel prefabs (blue, green, purple, red and yellow) can be found at Assets/Tutorial Resources/Prefabs/.
First, we’ll set up the object variables of the jewels. Add an object variable component to the prefabs (e.g. using the component menu: Makinom > Scenes > Object Variables). Change the following settings.
Click on Add Variable to add an object variable.
Next, we’ll add the Jewel Click schematic using an interaction machine component. The schematic handles the game controls, swapping jewels and searching/destroying matching jewels.
Add the component to the jewel prefabs (e.g. using the component menu: Makinom > Machines > Interaction Machine). Change the following settings.
Click on Add Condition, we’ll set up the game state condition here.
In the added Condition 0, we’ll set up our game state condition.
Click on Add Game State.
Destroying jewels is handled by the DestroyJewel schematic – which is started through a tagged machine on each jewel. In case you want to add special jewels that do something else upon being destroyed (e.g. destroy a whole row or column of jewels), you can create a different schematic and use it in this tagged machine.
Add a tagged machine component to the jewel prefabs (e.g. using the component menu: Makinom > Machines > Tagged Machine) and change the following settings.
Click on Add Starting Tag to add a starting tag
And that’s it – we don’t need to apply the changes, since we’ve been working on the prefabs directly.
Click on Play to test the game. You can now select and swap jewels by clicking on them – if matches are found after swapping jewels, they’ll be destroyed, leading to jewels above falling down, etc.
The player’s score and turns increase and are displayed by the HUD.
This concludes the match 3 game tutorial series. You can add additional content to the game, e.g. new levels, new jewels or new game modes (e.g. only having a defined amount of turns and having to reach a certain score).
© 2015 Gaming is Love e.U.
Disclosure: This site may contain affiliate links, which means I may receive a commission if you click a link and purchase something that I have recommended. While clicking these links won’t cost you any money, they will help me fund my development projects while recommending great assets!