IEnumerator Not Completing Entire Function
So I have an IEnumerator that handles my attack animation and various other things about the attack. It starts off great, however after the second yield return new WaitForSeconds()
all the code stops.
Here's a snippet:
Player.GetComponentInChildren<PlayerAttackScript().gameObject.GetComponent<PolygonCollider2D>().enabled = true;
PlayerAnimator.SetTrigger("AttackTrigger");
print("This prints");
yield return new WaitForSeconds(ClipTime);
Player.GetComponentInChildren<PlayerAttackScript().gameObject.GetComponent<PolygonCollider2D>().enabled = false;
GetComponentInChildren<PlayerAttackScript>().IsAttacking = false;
print("This will also print.");
if (ClipTime < (1 / PlayerAttackSpeed))
{
yield return new WaitForSeconds((1 / PlayerAttackSpeed) - ClipTime);
}
print("This wont print!");
isAttacking = false;
As shown, the prints execute stating which ones print, but anything after the second Wait() won't execute. Any ideas?
Ps. ignore the weird access I'm using to enable a collider.
Comment
Your answer
Follow this Question
Related Questions
nothing called after WaitForSeconds 1 Answer
Problem with force movement when calling from another scripts 0 Answers
C# waitForSeconds Question 1 Answer
WaitForSeconds 1 Answer
Automatic reloading issues 1 Answer