How can I spawn an item after killing a wave of 6 enemies?,How can I spawn an item after clearing a wave of 6 enemies?
Hi,
I'm at my wits end with this one trying to figure out how to end this argument. I'm trying to spawn an item after the last enemy has been killed by the player and all enemies in the wave must also die to be rewarded.
I have a script of the enemy that counts an int value on this script. When it hits 6, it spawns the buff but my two main issues are; spawning just one prefab item and; at the last enemies location.
Here's my current code:
public class Plane : MonoBehaviour { public bool waveOneKilled = false; public int enemyOneKillCount = 0; public GameObject powerUpPrefab; IEnumerator WaveOneBuff() { yield return new WaitForSeconds(0); Instantiate(powerUpPrefab, new Vector3(13, -6, 0), Quaternion.identity); } for (int i = 0; i < 1; i++) { if (enemyOneKillCount == 6) { StartCoroutine(WaveOneBuff()); } } }
Any help would be greatly appreciated! :)
Thanks.
Your answer
![](https://koobas.hobune.stream/wayback/20220612153158im_/https://answers.unity.com/themes/thub/images/avi.jpg)