In this recipe, we take care of instantiating a particle system prefab in the place of a collected item that disappears, and also use the particle system to play the sound effect we set for this specific game event.
To achieve this, we need a new script and need to make some modifications to the Runner script, so let's begin.
Create a new C# script in the Scripts folder of your project and name it PS_Manager.
Edit the
Update()
function so that it contains the following lines. They tell the PS to destroy itself once the audio attached to it has finished playing:void Update () { if(!audio.isPlaying){ Destroy(this.gameObject); } }
Now open the Runner script in Monodevelop, if you did not open before.
To begin with, we need a public GameObject variable to store the reference to the particle system prefab we are going to create in the scene. Add the following line to the...