Help With Initiating Bomb Every Specific Second

Hello,

I'm working on a Jet, and what it does is it finds a target with a tag of 'enemy', it then flys over the enemy and drops a bomb, and then flys away.

What I want though, is for the jet to drop a bomb every second whilst its above the enemy. This should be call in a function called 'Bomb()'

If you could help, that would be great!

Here is my script:

// --- Control Fighter Jets Flight AI --- \\

// - Jet Flight - \\
var targetTag : String;
var target : Transform;
private var speed : float = 30;
var damping = 2;
var distance : int;
var distanceExit : int;
var exit : Transform;
var follow : boolean = true;
var dropBombs : boolean = false;
var bomb : Rigidbody;
var bombSpawn : Transform;

// - DamageControl - \\
var explosion : GameObject;
var damage = 80;
var deadReplacement : Rigidbody;

function OnCollisionEnter(collision : Collision)
{
    Detonate ();    
}

function Update () {
    var tar = GameObject.FindWithTag(targetTag);
    if(tar)
    target = tar.transform;
}

function LateUpdate(){
    // --- Finds target, and follows it --- \\
    if(follow == true)
    {
        var lookAt = target.position - transform.position;
        lookAt.y = 0;
        var rotation = Quaternion.LookRotation(lookAt);
        transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
        transform.Translate(Vector3.forward*speed*Time.deltaTime);
        // --- Once jet is within a distance of enemy, it will stop following --- \\
        var distance = transform.position.x - target.position.x;
        if(distance < 5){
            follow = false;
        }
        // --- Activate bomb dropping within a ditance --- \\
        if(distance < 10){
            Bomb();
        }
    }
    // --- Fly to exit waypoint --- \\
    if(follow == false){
        var lookAtExit = exit.position - transform.position;
        var rotationExit = Quaternion.LookRotation(lookAtExit);
        transform.rotation = Quaternion.Slerp(transform.rotation, rotationExit, Time.deltaTime * damping);
        transform.Translate(Vector3.forward*speed*Time.deltaTime);

    }
    // --- Destory jet when at exit waypoint --- \\
    var distanceExit = transform.position.x - exit.position.x;
    if(distanceExit < 5){
        Destroy(gameObject);
    }
}
// --- Destory jet when collider is true --- \\
function Detonate () {

    Destroy(gameObject);

    if (explosion)
        Instantiate (explosion, transform.position, transform.rotation);

    if (deadReplacement) {
        var dead : Rigidbody = Instantiate(deadReplacement, transform.position, transform.rotation);
        dead.rigidbody.velocity = rigidbody.velocity;
        dead.angularVelocity = rigidbody.angularVelocity;
    }
    var emitter : ParticleEmitter = GetComponentInChildren(ParticleEmitter);
    if (emitter) {
        emitter.emit = false;
        emitter.transform.parent = null;
    }
}

// ---- Experimental Bomb ---- \\
private var nextFireTime = 0.0;
private var m_LastFrameShot = -1;
private var fireRate = 0.2;

function Bomb(){
    if (Time.time - fireRate > nextFireTime)
        nextFireTime = Time.time - Time.deltaTime;

    while( nextFireTime < Time.time) {
    BombOneShot();
    nextFireTime += fireRate;
    }
}

function BombOneShot(){
    Instantiate (bomb, bombSpawn.position, transform.rotation);
    dropBombs = false;

    m_LastFrameShot = Time.frameCount;
}

Thanks All!

Right, well that was a lot more easier than I thought.

just needed a InvokeRepeating("Bomb", 0, 1);