Hey guys!
I’m in the process of creating some fireballs for my game, however, everything doesn’t work out as i want them to do.
The Particle emitter is attached to the “Fireball” prefab, which is set to be destroyed on the collision, and at the same time, detaching the child objects (which is the Fire Particle Emitter, that’s following the fireball itself, to create the fire effect).
However, i want to “turn off” the emitters before destroying them, but this is where i can’t find the right solution.
This is how my current solution is, however, I’m pretty sure it isn’t optimal, as i only have 1 instance of the variable “HasCollided”, making all of my “flame” prefabs, which is the Particle Emitters Name, turn off, which isn’t optimal, if there’s still fireballs in the air at the time of some other fireball may trigger the script.
The following script is attached to my fireball “ball”.
static var HasCollided = false;
function OnCollisionEnter(collision : Collision)
{
HasCollided = true;
transform.DetachChildren();
Destroy (gameObject);
Debug.Log("Check");
}
and this script is attached to my “Fire” prefab, that contains 4 different elements - 3 particle and 1 light source. (However, this isn’t working, as i can’t turn off my emitters!)
var InnerCore : ParticleEmitter;
var Smoke : ParticleEmitter;
var OuterCore : ParticleEmitter;
function Update () {
FlameStop();
}
function FlameStop()
{
if (Explosion.HasCollided == true)
{
InnerCore.emit = false;
OuterCore.emit = false;
Smoke.emit = false;
yield WaitForSeconds(5);
Destroy(gameObject);
HasCollided = false;
}
}
So, can anyone shed some light on a fail, or just a different solution, so i might be able to have more fireballs in the air, than one.
Thanks in advance! :))
//Anders Schou - Trixxr.com