help expected. Insert a semicolon at the end
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;"
Answer by Positive7 · Aug 23, 2015 at 05:29 PM
var theParticles = GetComponent ParticleEmitter.particles;
To
var theParticles = GetComponent(ParticleEmitter).particles;
And the full code :
#pragma strict
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 < GetComponent(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
GetComponent(ParticleEmitter).particles = keepParticles;
}
ok and now ? Error BCE0020: An instance of type 'UnityEngine.ParticleEmitter' is required to access non static member 'particleCount'. (BCE0020) (Assembly-UnityScript) on : for (var i = 0; i < ParticleEmitter.particleCount; i++ )
for (var i = 0; i < ParticleEmitter.particleCount; i++ )
To
for (var i = 0; i < particleEmitter.particleCount; i++ )
Your answer
Follow this Question
Related Questions
Build Errors Fixing Method 0 Answers
Error building player because scripts have compile errors in the editor 1 Answer
Build error Execution failed for task ':packageReleaseBundle'. 0 Answers
game demo run button is not working 0 Answers
I can not build my project in Unity Version 2018.3.12f1 1 Answer