Setting up the schematic to handle the destruction of a jewel.
In this tutorial we’ll create the schematic that’s started (by a tagged machine on the individual jewels) when a jewel is destroyed. It’ll handle animating the destruction (blinking and spawning a particle effect), increasing the player’s score (the points of each jewel are stored in an object variable on the jewel) and destroying the game object.
In case you want to add special jewels (e.g. destroying a whole row/column or all nearby jewels), this is where you’d add the functionality, either directly in this schematic or creating new schematic and using them in the tagged machine on the jewel.
Open the Makinom editor, navigate to Schematics and create a new schematic. Change the following settings.
We need a prefab resource for the particle effect.
Click on Add Prefab Resource to add a prefab resource.
Add Node > Game Object > Renderer > Change Color
We’ll use this node to start blinking the object by fading it’s alpha (color) value.
Add Node > Base > Wait
We’ll wait for 0.5 seconds to give the game object some time for blinking.
Add Node > Game Object > Prefab > Spawn Prefab
Now, we’ll spawn the particle effect.
Add Node > Game Object > Prefab > Destroy Prefab
Next, we’ll destroy the particle effect (after 1 second).
Add Node > Audio > Audio > Play Sound
We’ll play a destruction sound.
We’ll wait for 0.25 seconds for the particle effect and audio to play a bit before destroying the game object. Also, this allows the blinking to fade from full alpha to no alpha (due to blink duration of 0.25 and already having waited for 0.5 seconds).
Add Node > Value > Variable > Change Variables
We’ll use this node to increase the player’s score (global int variable) by the points of the jewel (object int variable on the jewel).
Click on Add Variable to add a variable change.
Add Node > Game Object > Game Object > Destroy Object
Finally, we’ll destroy the machine object (jewel).
And that’s it for the schematic – click on Save Schematic and save it as DestroyJewel in Assets/Schematics/.
The next tutorial will handle the game controls.