This function is supposed to find the emitter that the object has, but it never gets into the if. (It’s the code from the fps tutorial) I don’t get why it doesn’t exist.
function Kill ()
{
// Stop emitting particles in any children
var emitter : ParticleEmitter = GetComponentInChildren(ParticleEmitter);
if (emitter)
{
emitter.emit = false;
transform.DetachChildren();
Destroy(gameObject);
}
}
I’ve had similar issues before, now I don’t trust the GetComponentsInChildren anymore. IIRC, I’ve got the generic version to work more often than the normal method. I wouldn’t swear it but you give it a try tell us, heh.
GetComponentInChildren.<ParticleEmitter>(); //JS syntax requires a dot
GetComponentInChildren<ParticleEmitter>(); //C# doesn't