Quantcast
Channel: Questions in topic: "random spawn"
Viewing all articles
Browse latest Browse all 125

Spawning enemies javascript

$
0
0
I have enemies spawning randomly in few positions. My problem is that sometimes when you kill one of them, another spawns in exactly same position without any delay at all, so when you think you have killed that enemy there is another at his place shooting at you. Is there any way that I could delay spawn of enemy in position that I have just killed one? function CreateMob() { var randPosIndex: int = Random.Range(0, spawnPositions.Length); var randMobIndex: int = Random.Range(0, enemies.Length); var mobInst: GameObject = Instantiate( enemies[randMobIndex], Vector3(0, 0, 0), Quaternion.identity); var enemyBehaviour: EnemyBehaviour = mobInst.GetComponent(EnemyBehaviour); enemyBehaviour.x = spawnPositions[randPosIndex].x; enemyBehaviour.y = spawnPositions[randPosIndex].y; enemyInstances.Push(mobInst); enemyTimeouts.Push(enemyBehaviour.damageTimeout); }

Viewing all articles
Browse latest Browse all 125

Trending Articles