Help On Multi Missile Launcher

Hello,

On my game, I have a multi missile launcher, which right now just initiates a missile when the user clicks. The missile launches in the exact same place.

How can I go about making the missiles spawn from different positions, my launcher has different missiles in it. Like this:

alt text

So here are the layout of my launcher:

O-O-O

O-O-O

How can I go about it firing first from the top left, down to the bottom right?

Here is my missile launcher script:

var projectile : Rigidbody;
private var speed = 5;
var RocketsOn : boolean = false;

function Update()
{

    if(RocketsOn == true){
        print("ML Reached - Rockets = true");
    if(Input.GetButtonDown("Fire1"))
    {
        var instantiatedProjectile : Rigidbody = Instantiate(projectile, transform.position, transform.rotation);

        instantiatedProjectile.velocity =
            transform.TransformDirection(Vector3(0, 0, speed));

        Physics.IgnoreCollision(instantiatedProjectile. collider,
            transform.root.collider);

            return;

    }
}}

This script is added to a game empty within my scene, so the spawn position of my missile is dependent of my game object.

Thanks, Ollie

Based on your script i've added a timer and slots to hold each missiles position. sorry my mistake, I've edited it and test it. it works just fine. just do the same and it must work.

var projectile : Rigidbody;
var speed = 5;
var RocketsOn : boolean = false;
var missileSlots:Transform[]; //Assigne dummy objects to hold each missiles position.
var timeInterval:float = 0.1; //seconds to wait before next launch.
var startTime:float; //used in Timer().
var missileIndex:int = 0;

function Update() {
    if(Input.GetButtonDown("Fire1")) {
        RocketsOn= true;
    }
        if (Timer(timeInterval) && RocketsOn){ //Check whether it's the time for the next launch.
            if (missileIndex <=missileSlots.length-1){
                LaunchMissiles(missileSlots[missileIndex]);
                missileIndex++; 
            } else {
                missileIndex =0;
                RocketsOn = false;
            }
        }

}

function Timer(interval:float):boolean{

    var timer =  interval - (Time.time - startTime);
    if (timer <= 0){
        startTime = Time.time;
        timer =0;
        return true;
    } else {
        return false;
    }

}

function LaunchMissiles(slot:Transform){

    if(RocketsOn == true){
        print("ML Reached - Rockets = true");

        var instantiatedProjectile : Rigidbody = Instantiate(projectile, slot.position, slot.rotation);

        instantiatedProjectile.velocity =
            transform.TransformDirection(Vector3(0, 0, speed));

        Physics.IgnoreCollision(instantiatedProjectile. collider,
            transform.root.collider);

            return;

    }

}