Quantcast
Viewing all articles
Browse latest Browse all 1488

Please, I need help, I'm trying to create a Coroutine where my enemy shoots 1 pack of 4 bullets, every 2 seconds, but it just ended up in the enemy shooting some bullets and then never again

IEnumerator Shoot() { while(quantBullet <= 4) { GameObject bullet = Instantiate(bulletPrefab, shotSpawner.position, shotSpawner.rotation); Rigidbody2D rb = bullet.GetComponent(); rb.AddForce(shotSpawner.up * bulletForce, ForceMode2D.Impulse); quantBullet++; yield return new WaitForSeconds(2f); if (quantBullet == 4) { pack = true; } if(pack == true) { yield break; } yield return null; } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>