Question by
ozeol · Aug 25, 2021 at 06:19 AM ·
animationparticlesparticlesystemparticle systemparticle
While particle system is alive play animation.
I have a falling cannonball attack that I would like the enemy units to continuously play the "getting hit" animation. I have tried both isPlaying and isAlive so far and I think the problem is with the while loop. Please can someone advise? The code below seems to completely crash the game as well when the attack is launched.
void Update () {
GameObject cannonball = GameObject.Find("Cannonball");
GameObject ROF = GameObject.Find("RainOfFire2");
if (cannonball.transform.GetChild(5).gameObject.GetComponent<ParticleSystem>().IsAlive() || ROF.transform.GetChild(5).gameObject.GetComponent<ParticleSystem>().IsAlive())
alive = true;
else
alive = false;
foreach (Unit unit in enemy.units)
{
while (alive == true)
{
unit.photonView.RPC("HitAnimate", RpcTarget.Others);
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Particle System Particles Not Following Rotation 1 Answer
changing the radius of a particle system with unity script 1 Answer
Moving particle system via script causes choppy movement in build but works fine in pay mode 1 Answer
Are there any disadvantages to using the legacy Ellipsoid Particle System in Unity 5 over Shuriken. 0 Answers