I have a simple code that spawns particles when the player gets stopped at the trigger. But they do not stop being issued and I would like them to stop after a few seconds. How can I do this?
if (other.gameObject.tag == "Player" && Input.GetKeyDown(KeyCode.E))
{
PlayerManager.health += 1;
MyParticleEffect.SetActive(true);
yield WaitForSeconds(5); // wait for 5 seconds
MyParticleEffect.SetActive(false); // turn the particle system on
Debug.Log("e key was pressed");
}