Game Development Reference
In-Depth Information
Particle system effects
The last touch is to add some particle system effects to be played when the aliens
and the player's ship get destroyed.
As we already showed how to create a particle system to our scene, we will just
provide here the values to be set within and the coding required for the particle effect
to be played.
1. Add a
Particle System
to the scene and edit it with the following reference
values:
• General:
• Duration: 0.5
• Start Lifetime: 0.5
• Start Speed: 3
• Start Size: 1
• Looping: unflagged
• Play on Awake: flagged
• Emission:
• Rate:15
• Shape:
• Shape: Sphere
• Radius: 0.5
• Emit from Shell: flagged
2. We don't need much more than that for a prototype. Now create a new prefab
in the
Prefab
folder, name it
AlienPS
and drag the particle system from the
scene into this prefab, then delete the particle system from the scene.
3. In the
ControlPLBullet
script we need to declare a new variable to hold
our
AlienPS
prefab. Add the following line at the top of the script:
//var used to store the alien destroyed PS
var AlienPS:Transform;
4. Then in the
OnTriggerEnter()
function add the following line beneath the
audio.Play()
instruction: