I downloaded the Unity Particle pack and used an explosion in my game. I also want a sphere to appear or disappear based on current particle frame. I have calculated it to appear for 1 second, then hide for another.
First run goes ok, then the coroutine starts distorting time, eventually playing the animation on reverse of the particle, and then reaching proper display again. Any clues?
IEnumerator ActivateDeathSphere()
{
while (!hasExploded)
{
hasExploded = true;
foreach (GameObject card in cards)
{
GameObject deathsphere = card.transform.GetChild(1).gameObject;
deathsphere.transform.GetChild(0).GetComponent<MeshRenderer>().enabled = true;
}
yield return new WaitForSeconds(1f);
foreach (GameObject card in cards)
{
GameObject deathsphere = card.transform.GetChild(1).gameObject;
deathsphere.transform.GetChild(0).GetComponent<MeshRenderer>().enabled = false;
}
yield return new WaitForSeconds(1f);
hasExploded = false;
}
}