I am having trouble with on trigger exit function. When I enter the trigger it works properly, but even if im still in the trigger the OnTriggerExit Function will activate. Please help.
Code:
var trigger : int = 1;
var detection : int = 1;
var Timer : int = 2000;
function Start () {
}
function OnTriggerEnter (other : Collider) {
detection = 3;
}
function OnTriggerExit (other : Collider) {
detection = 2;
if(detection == 2)
{
yield WaitForSeconds (5);
Debug.Log("Ware is he?");
}
}
function Update () {
if(detection == 3)
{
if(trigger == 1)
{
Debug.Log("Get Him!");
trigger = 0;
}
}
}