GetComponent<ParticleEmitter>() Problem

Hi all,
Im having problem with rain script i found online.
When i import it into my project im getting this
‘‘Assets/RainAssets/scripts/findcollideparticles.js(19,28): BCE0144: ‘UnityEngine.Component.particleEmitter’ is obsolete. Property particleEmitter has been deprecated. Use GetComponent() instead. (UnityUpgradable)’’
Here is the code

var burstEnergy : float = 10.0;
var explosionObject : Transform;

function LateUpdate () {
    var theParticles = particleEmitter.particles;
    var liveParticles = new int[theParticles.length];
    var particlesToKeep = 0;
    for (var i = 0; i < particleEmitter.particleCount; i++ )
    {
        if (theParticles[i].energy > burstEnergy)
        {
            theParticles[i].color = Color.yellow;
            // We have so much energy, we must go boom
            if (explosionObject)
                Transform.Instantiate(explosionObject,
                    theParticles[i].position, 
                    Quaternion.identity );
       
        } else {
            liveParticles[particlesToKeep++] = i;
        }
    }
    // Copy the ones we keep to a new array
    var keepParticles = new Particle[particlesToKeep];
    for (var j = 0; j < particlesToKeep; j++)
        keepParticles[j] = theParticles[liveParticles[j]];
    // And write changes back
    particleEmitter.particles = keepParticles;
}

I have tried changing it to
var theParticles = GetComponent.particles;
var theParticles = GetComponent.(particles);
var theParticles = GetComponent();
But non of these worked does anyone know how to fix this :?

var theParticles = GetComponent<ParticleEmitter>().particles;

You were this close.

Doesn’t the UnityScript look like this?

var theParticles = GetComponent(ParticleEmitter).particles;
2 Likes

Thanks, it works, i was close xD