Game Development Reference
In-Depth Information
//create ps here
Instantiat(AlienPS,
other.transform.position,other.transform.rotation);
5. To complete the process, we add a very simple script to the AlienPS prefab
so that after the particle effects have been played, we can destroy it.
6. Create a new JavaScript file in the Script folder, name it DestroyPS and
add the following lines into it:
#pragma strict
var myPS:ParticleSystem;
function Start () {
}
function Update () {
if(!myPS.isPlaying )
{
//wait for the PS to finishing
playing before
//destroying the PS
Destroy(gameObject);
}
}
7. The last step is to add the script to the AlienPS prefab and drag the Ali-
enPS prefab into the myPS variable of the script.
The same approach applies to the particle effect to be added to the player's ship, in
case it is destroyed. Now, you should be able to figure it out by yourself.
Unity 3D tutorial summary
This ends our tutorial about using Unity to develop games. In the first part of Chapter
8 , Mobile Game Engines , we set up a scene, in the second part of Chapter 9 , Pro-
Search WWH ::




Custom Search