ai jump over object

right now i have enemies going towards each ay point. Im making a tower defence game and am planning on making a special turret where the enemies will have to jump over it. There will only be the one turret where i will make this happen so i have simplified my code to only take into account of this special turret. My problem is that when the enemy jumps it continually jumps to the other waypoints. It looks good but what i want is it just to jump over the collided object then land on the ground.

Code: using UnityEngine; using System.Collections;

public class EnemyWayPoints : MonoBehaviour {

public bool Turrethit = false;
public bool isGrounded = true;

public Transform[] waypoint;

private int currentWayPoint;

public float jumpspeed = 8.0f;
public float gravity = 20.0f;

public Vector3 target;
public Vector3 moveDirection;
public Vector3 velocity;
public Vector3 jump;

public float speed = 20.0f;

// Use this for initialization
void Awake()
{
    waypoint[0] = GameObject.Find("WayPointMain").transform;
    waypoint[1] = GameObject.Find("WayPoint1").transform;
    waypoint[2] = GameObject.Find("WayPoint2").transform;
    waypoint[3] = GameObject.Find("WayPoint3").transform;
    waypoint[4] = GameObject.Find("WayPoint4").transform;
    waypoint[5] = GameObject.Find("WayPoint5").transform;
    waypoint[6] = GameObject.Find("WayPoint6").transform;

}

// Update is called once per frame
void Update()
{

    if (currentWayPoint < waypoint.Length)
    {
        target = waypoint[currentWayPoint].position;
        moveDirection = target - transform.position;
        transform.LookAt(waypoint[currentWayPoint]);
    }

    velocity = rigidbody.velocity;

    if (moveDirection.magnitude < 1)
    {
        currentWayPoint++;
    }
    else
    {
        velocity = moveDirection.normalized * speed;
    }
    rigidbody.velocity = velocity;

    if (Turrethit == true)
    {
        transform.Translate(Vector3.up * jumpspeed * Time.deltaTime);           
        isGrounded = false;
    }

    moveDirection.y -= gravity * Time.deltaTime;
}

public void OnCollisionEnter(Collision hit)
{
    if (hit.collider.tag == "STurret")
    {
        Turrethit = true;
    }
  }

}

i know i havent added into make it hit the ground again and tryed looking at fps script but i dnt really understand how it works. i would like to understand how it works so i know what to do in future projects. thanks in adavance :)

I'm noticing something wrong with your code. You never turn off TurretHit, so once it's been turned on, your enemies repeatedly jump with nothing telling them to stop (nothing that turns TurretHit to false).

public CharacterController controller;

void Start(){

controller = gameObject.GetComponent(CharacterController);

}

void Update(){

if (controller.isGrounded == true && Turrethit == true ){

Turrethit = false;

}


}