Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Destroy function destroying only one object and not destroying his clones

$
0
0
Hello i'm new to Unity and i'm having trouble with some coding. I'm developing a tower defense idle game. My problem is i need to destroy all my enemies when my tower hp reaches 0. Then i will be spawned the last wave i was able to beat. But only one or 2 enemies are being destroyed and some remain on the screen and either get destroyed by the tower adding gold or hit it reducing the hp before the new wave spawn. Here is the code i'm using : void Update() { if (TowerHp.Hp <= 0) { if (!run) { run = true; TowerHp.Hp = TowerHp.startHp; waveSpawner.EnemiesAlive = 0; waveSpawner.waveIndex-=2; Destroy(gameObject); return; } else { run = false; } }

Viewing all articles
Browse latest Browse all 508

Trending Articles



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