private IEnumerator Attack(int spellIndex) { Transform currentTarget = Target; Spell s = spellBook.PrepareSpell(spellIndex); IsAttacking = true; animator.SetBool("cast", IsAttacking); yield return(new WaitForSeconds(s.GetCastTime)); //attack delay if (Target != null && InLineOfSight()) { SpellController spell = Instantiate(s.GetPrefab, exitPoints[exitIndex].position, Quaternion.identity).GetComponent <SpellController>(); spell.Initialize(Target, s.GetDamage); } StopAttack(); }