making a variable (var) false when not colliding with a trigger.

hi, i have this script which is meant to have ‘OnLand’ true when inside the trigger collider (which it does fine) but i want it to be false when not inside the trigger collider. this is my script:

var OnLand = false;

function OnTriggerEnter (hit : Collider) {
	if(hit.gameObject.tag == "area"){
		OnLand = true;
	}else{
		OnLand = false;
	}
}

any ideas? thanks for your time…

Use OnTriggerExit

var onLand = false;

function OnTriggerEnter (hit : Collider) {
    if (hit.gameObject.tag == "area") {
        onLand = true;
    }
}

function OnTriggerExit (hit : Collider) {
    if (hit.gameObject.tag == "area") {
        onLand = false;
    }
}

Your current code will only set onLand to false when you hit a trigger that is not tagged “area”, otherwise it will continually be set to true even if you’re not colliding with it anymore.