I have a boss that summons spawn enemies, but I only want one enemy spawned per spawn point. So I’m not sure what’s going on within my code that causes it to spawn many enemies at the same location.
bool isSpawned;
Start()
{
isSpawned = false;
}
//transition ability
void RaiseDead()
{
if(Input.GetKey(KeyCode.Alpha1))
{
animation["Summon"].wrapMode = WrapMode.Loop;
animation.CrossFade("Summon");
auraHand.Play();
shieldWall.Play();
shieldWallCollider.enabled = true;
StartCoroutine(SummonDead());
}
}
IEnumerator SummonDead()
{
//spawn summoning particles
yield return new WaitForSeconds(3);
summonParticle1.Play();
//spawn skeletons
if(!isSpawned){
yield return new WaitForSeconds(3);
Instantiate (skeleton, spawnPoint1.position, spawnPoint1.rotation);
isSpawned = true;
}
//despawn summoning particles
yield return new WaitForSeconds(1);
summonParticle1.Stop();
yield break;
}