Coroutine and homing missiles not getting along

Heres my existing code for a missile projectile that I have. What I would like is for my missile to do is once its fired go up along the y axis (in this case straight up) for a frame or two then target the enemy. Ive implemented a coroutine but of course its wrong because now my script wont compile at all.

Now based on what I’ve been researching a coroutine would be the best way to go. I believe that I’ve placed the code in the right spot but it doesn’t work.

Can someone please point out the error for me.

Thanks

var myExplosion : GameObject;
var myTarget : Transform;
var myRange : float = 10;
var mySpeed : float = 10;
var myDamageAmount : float = 25;

private var myDist : float;

function Start ()
{
audio.Play();
}

function MissleMoveUp()
{
transform.Translate(0,Time.deltaTime, 0);
yield WaitForSeconds (waitTime);
}

function Update ()

{
transform.Translate(Vector3.forward * Time.deltaTime * mySpeed);
myDist += Time.deltaTime * mySpeed;
if(myDist >= myRange)
Explode();

if(myTarget)
{
transform.LookAt(myTarget);
}
else
{
Explode();

}
}

function OnTriggerEnter(other : Collider)
{
if(other.gameObject.tag == “Enemy” || other.gameObject.tag == “Air Enemy”)
{
Explode();
other.gameObject.SendMessage(“TakeDamage”, myDamageAmount, SendMessageOptions.DontRequireReceiver);
}
}

function Explode()
{
Instantiate(myExplosion, transform.position, Quaternion.identity);
Destroy(gameObject);
}

Well, one, your missileMoveUp() uses waitForSeconds, but then does nothing. So, what is its purpose?

Second, use tags when posting.

Where have you defined waitTime?

Is this a missile with a rigidbody (not isKinematic)? If so, your code is bad…

check this thread for a better solution (at least for controlling the missile).

http://forum.unity3d.com/threads/196584-quot-Homing-Missile-quot-Script-problem/page2?p=1367484#post1367484

nice programming