OK now this is kind of strange. I had been working all weekend trying to figure this out, I eventually got my UFO to take off from the hilltop stone circle as my FPS player gets within a certain range and I've even managed to have the UFO destroy itself with and animation event at the end of the clip and replace the UFO with a dead replacement complete with a Ragdoll dead Alien Zombie that slumps over nicely in the seat when the UFO dead replacement "Instantiates" got some fire happnin too with a nice cracking fire sound. I still have not been able to figure out how to get an explosion to occure about midway through the UFO's fight path though :(
The code works but I get a script error that says: "Update() can not be a coroutine" Whatever that means??
Here is my code that I've attached to my UFO that the animation event calls upon if you would like to have a look.
var UFOexplosionSound : AudioClip;
var explosion : GameObject;
var wreck : GameObject;
function ExplodeUFOsound (clip : AudioClip)
{
audio.PlayOneShot(UFOexplosionSound);
}
function Update () {
yield WaitForSeconds(3);
KillSelf();
}
function KillSelf () {
var wreckClone = Instantiate(wreck, transform.position, transform.rotation);
Destroy(gameObject);
}
Like I say it appears to work only I get that error message and I'm not sure if this is because my UFO Dead replacement is much more detailed than that of the UFO used for the animation but I guess about at the time in game when it's making the switch the game kinda freezes for a quick moment, not really a biggie I suppose but I'm wondering if there is a way to fix that.
After much hair pulling and teeth grinding I managed to get this script to work:
var explosion : GameObject;
var wreck : GameObject;
function ExplodeUFO()
{
Instantiate(explosion, transform.position, transform.rotation);
}
function KillSelf () {
yield WaitForSeconds(3);
var wreckClone = Instantiate(wreck, transform.position, transform.rotation);
Destroy(gameObject);
}
I was even able to get my mid air explosion to occure right at the exact keyframe I wanted it. Now to see if I can get a nice big explosion at the end of the animation... after all I figure that speedy UFO is likly to make a big bang lol :D