private IEnumerator PopAnimation() { int nParticles = UnityEngine.Random.Range(2, 6); for (int i = 0; i < nParticles; i++) { BulletParticle particle = Instantiate(bulletParticle, transform.position, Quaternion.identity); particle.GetComponent <Rigidbody2D>().velocity = new Vector2(UnityEngine.Random.Range(-1, 1), UnityEngine.Random.Range(0, 2)); } yield return(new WaitForSeconds(2)); Destroy(gameObject); yield return(null); }