My script doesn work Trigger Problem!! HELP!!

tell me what in my script is not good…beause the trigger doens work…

var Detect=false;

var AnyTag=false;

function Update () {}

function OnTriggerStay(Hit:Collider)

{

if(Hit.gameObject&&AnyTag){Detect=true;}

if(Hit.gameObject.tag==“terrain”){Detect=true;}

}

function OnTriggerExit(){Detect=false;}

Why is the AnyTag in the if ? Is that meant to be there because I see no other references . . . O.o

Try this:

var Detect : boolean = false ;

function Update ( ){

}

function OnTriggerStay ( collision : Collider )
{
   if ( collider.gameObject.tag == "terrain" )
   {
      Detect = true ;
   }
}

function OnTriggerExit ( collision : Collider )
{
   if ( collider.gameObject.tag == "terrain" )
   {
      Detect = false ;
   }
}

Did you guys forget that you need to have a rigid body attached to one of the game objects that are colliding to activate the trigger?
Check if this isn’t the problem!
I forget the link to the collision matrix, but try to find something about triggers collision on documentation and you will know about what I’m talking about.

Note: Will be better apply the rigid body to the game object that is moving, not the static one. Please check the documentation for further information.

Hope it helps =)

At least one of the game objects need to have a rigid body component attached to it if you wanna Unity to detect the trigger.

Please, take a loot at this: Unity - Manual: Box Collider component reference

In the end you have the collision matrix. =)

Can you post the code so I can take a look of it and try to find the problem?