How can I only call OnTriggerEnter Once?

I’m using a box collider to detect when my player has entered a specific area on the level. At that point I am using the trigger to call a camera zoom. This is so the camera will zoom in at the end of the level. I believe the trigger is getting called again and again while the player is inside the box collider, causing the zoom to be called endlessly ( and the camera to be shakey). The zoom works great when attached to a key to call it (which is where I found the example) and is stable when zoomed in. But when it’s attached to a box collider trigger its not so usable.

Does anyone have a suggestion that might help?

Here is the script attached to a box collider:

var zoom : int = 10;
var normal : int = 60;
var smooth : float = 5;


private var zoomedIn = false;

function Update () {

	if(zoomedIn == true){

		ZoomIN();
	}
	
	if(zoomedIn == false){

		ZoomOUT();
	}
}


function OnTriggerEnter(other : Collider){
	if(other.tag == "Player"){
		
		zoomedIn = true;
	}
}

function OnTriggerExit(other : Collider){
	if(other.tag == "Player"){
		
        zoomedIn = false;
	}
}

function ZoomIN(){
	Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView,zoom,Time.deltaTime*smooth);
}

function ZoomOUT(){

	Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView,normal,Time.deltaTime*smooth);
}

Your original code is correct…at least by itself. There may be other scripts or forces acting on your object that can cause problem. My comments were just to indicate that left to its own devices, ZoomIN or ZoomOUT will get called forever and it can take a long time to reach the destination. Is is possible that you have this script on more than one trigger? If so, they could fight with each other. If this is the problem, it’s not too hard to fix.