Help with bomb script

I have a script in which a bomb destroys anything that enters it as long as its in the blast zone and a variable is true.

#pragma strict

var explosion : boolean = false;

Invoke("bombdest", 3);
function bombdest(){
Destroy (gameObject);
Debug.Log ("bomb destroyed");
}

Invoke("explodetrue", 2.7);
function explodetrue(){
explosion = true;
Debug.Log ("bomb exploded");
}

function OnTriggerEnter (other : Collider) {
if (explosion == true) 
 Destroy(other.gameObject);
Debug.Log ("game object destroyed");
    }

The debug.log part goes off when I`m in the blast zone even if explosion is false BUT nothing gets destroyed

Thanks

1 Answer

1

Please pay attention to where the script is being attached. If you have group of objects that are intended to be destroyed, each of this object should have collider and function OnTriggerEnter attached to it. In this approach for function OnTriggerEnter (other : Collider), other is the bomb. In the contrary, if you attach on OnTriggerEnter to the bomb, you probably destroy only one object in the blast zone. Please refer at the collision matrix at http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html if you have the colliders properly set.

Thanks I have it figured out now

–