OnTriggerEnter Influencing all GameObjects of the Same Type

Hi,

I have a perfectly working trigger, but I have coded several cubes in the level to be destroyed when they collide with the trigger. The problem that I am having is that when the first collider hits the trigger, all the cubes coded for to be destroyed are all destroyed. What I want is for each cube to be destroyed only when they collide with the trigger.

Here is a snippet:

var lifeTime = 3.0;

function OnTriggerEnter(other:Collider){
    if(other.gameObject.tag=="Trigger1"){
    
	}
}

function Awake()
{
	Destroy (gameObject, lifeTime);
}

Thank you

Well what you are doing is destroying everything in your “Awake” function. Try this
var lifeTime = 3.0;

function OnTriggerEnter(other:Collider){
    if(other.gameObject.tag=="Trigger1"){
      Destroy (gameObject, lifeTime);
    }
}

You are destroying the cube in Awake method, that’s why!

Awake is called on every object once they are created.

Try with this code instead:

function OnTriggerEnter(other:Collider){
    if(other.gameObject.tag=="Trigger1"){
        Destroy(gameObject);    
    }
}