private IEnumerator AnimateAttack() { Ray ray = new Ray(transform.position + transform.localScale.y * 0.5f * Vector3.up, Player.transform.position - transform.position); if (mainModule.AwarnessModule.SeePlayer(AttackRange)) { if (!Physics.Raycast(ray, Vector3.Distance(transform.position, Player.transform.position), groundLayer)) { CancelInvoke("AttackPlayer"); animationController.CrossfadeAnimation("Attack", 0.1f); animationController.SetBool("IsAttacking", true); yield return(new WaitForSeconds(animationController.AnimationClips["Attack"].length * 0.5f)); ArcaneProjectile aProjectile = Instantiate(projectilePrefab, ProjectileOrigin.transform.position, Quaternion.identity).GetComponent <ArcaneProjectile>(); aProjectile.transform.position = new Vector3(aProjectile.transform.position.x, aProjectile.transform.position.y, 0f); aProjectile.Damage = Damage; aProjectile.KnockBackForce = KnockBackForce; aProjectile.ProjectileSpeed = ProjectileSpeed; aProjectile.TurnOffAutoTargetDistance = turnOffAutoTargetDistance; if (IQ >= 2) { aProjectile.IsAutoTargeted = true; } else { aProjectile.Direction = (Player.transform.position + Vector3.up - transform.position).normalized; } yield return(new WaitForSeconds(animationController.AnimationClips["Attack"].length * 0.5f)); animationController.SetBool("IsAttacking", false); yield return(new WaitForSeconds(Cooldown)); InvokeRepeating("AttackPlayer", 0, 1f); } } }