Hello all,
I'm having trouble using yield in order to wait for a particle emitter's particles to die before killing the emitter. I've read most of the related questions that Answers provides, but I still can't figure it out. Code:
var explosion : GameObject;
function OnCollisionEnter( collision : Collision )
{
var contact : ContactPoint = collision.contacts[0];
var rotation = Quaternion.FromToRotation( Vector3.up, contact.normal );
var instantiatedExplosion : GameObject = Instantiate(explosion, contact.point, rotation );
var core = transform.Find("Core");
core.GetComponent(ParticleEmitter).emit = false;
core.transform.parent = null;
Destroy(gameObject);
Destroy(core, 3);
print("HI"); //Print Out
// Waits 5 seconds
yield WaitForSeconds (5.0);
print("Bye"); //Print Out
instantiatedExplosion.transform.Find("smoke").GetComponent(ParticleEmitter).emit = false;
Destroy (instantiatedExplosion, 2);
//instantiatedExplosion.transform.Find("smoke").GetComponent(ParticleEmitter).maxEnergy
}
How come yield isn't working here? "Bye" never shows up. Or perhaps