unity3d: making the AI jump over obstacle with a tag

hi,

I have a simple AI which just goes forward. In front of the AI there is an obstacle (just a cube) with a tag “terrain”. What i want my AI to do is jump over it. Here is what i have:

#pragma strict

var Speed : float = 2;
var jumpSpeed : float = 8.0;
var vSpeed : float = 0.0;

function Awake () {
	myTransform = transform;
}

function Update () {

	if(jump == true){
		vSpeed = jumpSpeed;
	}
	if(jump == false){
		vSpeed = 0;
	}
    // not a very smooth jump but probably good enough
	myTransform.position += myTransform.up * vSpeed * Time.deltaTime;
    // move forward
	myTransform.position += myTransform.forward * Time.deltaTime * Speed;

}

function OnCollisionEnter(col : Collision){
	if(col.gameObject.tag == "terrain"){
		jump = true;
	}
}

// i don't think this part is working
function OnCollisionExit (col : Collision) {
	if(!col.gameObject.tag == "terrain"){
		jump = false;
	}
}

My AI does jump over the obstacle but then keeps jumping and i cant find a way to stop it from jumping

plz help

And thx in advance

Why did you negate the tag in OnCollisionExit? It seems like it should be:

function OnCollisionExit (col : Collision) {
  if(col.gameObject.tag == "terrain"){
    jump = false;
  }
}