Hiero Match : Adding Exploding Particles Whenever Tiles Removed

Unity 3 Blueprints

Unity 3 Blueprints

Hiero Match is a Matching/pairing game ‘tutorial’  using unity3d from the book UNITY 3 BLUEPRINTS, written by Craig Stevenson and Simon Quig, and published by Deep Pixel. This tutorial start from chapter 2 and finished to chapter 3.

In this blog, I will show you how to add exploding effect to the game whenever tiles removed.  we would need complete game project files from the book, you can download it here.

First we add new variable with Game Object Type to our tileGenerator.js script. This variable will be our GameObject to be called when we removed particle. here is the example

//define variable explosiveObject with GameObject type
var explosiveObject : GameObject;

Note that explosiveObject is still empty GameObject (none), we can assign it later.

Explosive Tiles Hiero Match

Explosive Tiles Hiero Match

After that we would Instantiate explosiveObject whenever we destroy our tiles, so we call method Instantiate(GameObject, Position(Vector3), Quaternion.identity) to create our explosive particle effect object to our scene. We will put this “Instantiate” code before we destroy our tiles object and when we get a match. For our case we put Instantiate method inside revealCardTwo() function, we must put it after we check that Object1 and Object 2 is paired/get a match and before we destroy object1 and object2. here is the example 

function revealCardTwo(){
	//~~~ some code from Hiero Match > tileGenerator.js
		// check if Object 1 name and Obejct 2 name is same or paired
		if (tName1[0] == tName2[0]){
			// instantiate explosion effect using object1 position
			Instantiate(this.explosiveObject, matchOne.transform.position , Quaternion.identity);
			// instantiate explosion effect using object1 position
			Instantiate(this.explosiveObject, matchTwo.transform.position , Quaternion.identity);
			//destroy object 1 and object 2
			Destroy(matchOne);
			Destroy(matchTwo);
			//~~~ some code from Hiero Match > tileGenerator.js
		}
	//~~~ some code from Hiero Match > tileGenerator.js
}

Now we have finished with our exploding code and we have empty Game Object on our tileGenerator, we have to assign it with exploding particles. We have to import our particles first, we will use standard unity3d particles. Go to Assets > Import Package > Particles. Then import package window show up, we can select some of particles effect (don’t forget to select it’s material, animation and script) or All of them, Then click import button below. Now Standard Assets Folder and Particles Sub Folder appear in your Project View. You can try each of particles effect with dragging each particle prefab to Hierarchy View, and change it’s properties in Inspector View to get different effect of particle.

Of course you could use any particle effect to become our explosion effect, but for this tutorial I will use ‘small explosion’ particle prefab just like in my demo. So, we go to Project View and navigate to folder Standard Assets > Particles > Legacy Particles, then we drag ‘small explosive’ prefab to our Hierarchy View, we can see it’s effect in our Scene View or Game View, now we set our ‘small explosive’ properties in our Inspector View like images below.

Particle Properties

Particle Properties

Note that you could modify your own explosive effect and try to experimenting for every properties value and option as much as you like. but we must check auto destruct option under particle animator section and also Check one shot option under ellipsoid particle emitter. This will create effect that last only for one shot / one animation and automatically move to garbage collection.

Last, we will assign our modified explosive particle to our empty explosiveObject variable on tileGenerator.js. before that we must apply our change to our prefab, select our particle on Hierarchy View than go to menu GameObjects > Apply Changes to prefab, now we can remove our particle from Hierarchy View by right clicking it and choose delete. Then we select tileGenerator Object on Hierarchy View, on the Inspector View we change Explosive Object under tile Generator (Script) to Small Explosion, or click on circle button beside to open ‘Select Game Object’ Window and select Small Explosion.

Now you can test it with play button on unity3D windows, and Voila, your tiles will have exploding effect whenever we have a MATCH !

You can try the modified game here >>

and also checking our Hiero Match tutorial.
1. 2. Hiero Match : Adding Exploding Particles Whenever Tiles Removed
3. Hiero Match : Speeding Up The Timer Whenever Tiles didn’t Matched
4. Hiero Match : Adding Start Menu GUI
5. Hiero Match : Add New Challenge “Rotating Tiles”
6. Hiero Match : Polish Your Game a Little bit ‘Shine’

9 Opinion to this post

  1. [...] checking our Hiero Match tutorial. 1. Hiero Match : Add New Challenge “Shuffle Tiles” 2. Hiero Match : Adding Exploding Particles Whenever Tiles Removed 3. Hiero Match : Speeding Up The Timer Whenever Tiles didn’t Matched 4. Hiero Match : [...]

  2. louis vuitton store says:

    Very good written post. It will be supportive to everyone who employess it, as well as myself. Keep doing what you are doing – can’r wait to read more posts.
    louis vuitton store http://louisvuittonstores2013.overblog.com

  3. [...] Match : Add New Challenge “Shuffle Tiles” 2. Heiro Match : Adding Exploding Particles Whenever Tiles Removed 3. Heiro Match : Speeding Up The Timer Whenever Tiles didn’t Matched 4. Heiro Match : [...]

  4. バーバーリコピー says:

    万物は次の店頭販売後、商品を含むばかりでなく彼は収蔵数年の珍品腕時計、そしてベルギーダイヤモンド、友人の委託販売の翡翠、妻のアクセサリーを買う。

  5. 草間彌生 ルイヴィトン says:

    騙されてるのは経験のないヲタクだけ。

  6. [...] checking our Hiero Match tutorial. 1. Heiro Match : Add New Challenge “Shuffle Tiles” 2. Heiro Match : Adding Exploding Particles Whenever Tiles Removed 3. Heiro Match : Speeding Up The Timer Whenever Tiles didn’t Matched 4. Heiro Match : [...]

  7. [...] checking our Hiero Match tutorial. 1. Heiro Match : Add New Challenge “Shuffle Tiles” 2. Heiro Match : Adding Exploding Particles Whenever Tiles Removed 3. Heiro Match : Speeding Up The Timer Whenever Tiles didn’t Matched 4. Heiro Match : [...]

  8. Marian says:

    I like this post, enjoyed this one appreciate it for putting up.

  9. [...] checking our Hiero Match tutorial. 1. Heiro Match : Add New Challenge “Shuffle Tiles” 2. Heiro Match : Adding Exploding Particles Whenever Tiles Removed [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comment moderation is enabled. Your comment may take some time to appear.