Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Enemy Spawn script not continuing level

$
0
0
I have a enemy spawn script that spawns enemies and increases its level every 20 enemies that appear. So on level 4 i have an special enemy that appears but after you destroy the enemy the level does not advance and no more enemies are created here is my script var isON: boolean = true; var level: int; function Update () { if (isON){ transform.Translate(Vector3(direction * speed * Time.deltaTime,0,0)); if (Time.time > lastSpawn + nextSpawn){ Instantiate(enemy, transform.position, Quaternion.identity); level = manager.ShipCounter(); manager.ShipCounter(); lastSpawn = Time.time; nextSpawn = Random.Range(1.0,3.0 - (.2 * level)); } } if (level == 4 && isON == true){ isON = false; Instantiate(Enemyred, Vector3(0,8,2), Quaternion.identity); } } I tried multiple approaches as removing the "isON = false;" but that just adds more than 1 enemy in the game and floods my gamescreen. Be great if anybody can help. P.S. (IsON) is a trigger where i can either turn the spawner off or on during something situations i want to turn it back on after i destroy a specific enemy

Viewing all articles
Browse latest Browse all 1488

Latest Images

Trending Articles



Latest Images

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