var burstEnergy : float = 10.0;
var explosionObject : Transform;
function LateUpdate() {
var theParticles = GetComponent 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;
}
ERROR:
Error UCE0001: ';' expected. Insert a semicolon at the end. (UCE0001) (Assembly-UnityScript) on: "var theParticles = GetComponent ParticleEmitter.particles;"
↧