i have a 2d space shooter.
The bullet prefab is contains a script and attached component is explosion transform.
when my bullet hits asteroid it instantiates the explosion and it is destroyed but i still have explosion clones
Why are they not destroyed since they are attached to the bullet prefab and bullet objects are destroyed
my Bullet script
var bulletSpeed : float = 15.0; //bullet speed
var vertMax : float =10; //height of bullet
var explosion : Transform;
function Start () {
}
function Update () {
transform.Translate (0, bulletSpeed*Time.deltaTime, 0);
if (transform.position.y>=vertMax){
Destroy(gameObject);
}
}
function OnTriggerEnter(other:Collider){
if (other.gameObject.tag=="asteroid"){
other.transform.position.y=10; //reset "other" object (asteroid)
//transform.position.x= Random.Range(7,-7);
//create explosion
Instantiate (explosion, transform.position, transform.rotation);
Destroy(gameObject);
}
}