I hate to keep posting about the same things, but I am just not able to get this working exactly right…
What I want to have happen is when the user clicks the left mouse button, it fires off _isAttacking to true. I got that working and my animation array starts to play. The issue is this. How can I tell EXACTLY how long my animations are going to take to run so that my yield only waits that exact amount of time? What is happening is that when I click the button, it plays through the loop the first time, then any other time it plays through intermittently. I just simply want to play all the animations in my array when the button is clicked. But if its clicked again in the middle of the first loop, I DONT want it to start over, I just want it queued up to play again. Any help is greatly appreciated
AnimationState attackAnim;
IEnumerator PlayAttackSequence()
{
float yieldTime = 0.0f;
animation.wrapMode = WrapMode.Once;
for (int attackCntr = 0; attackCntr < arrMeleAttacks.Length; attackCntr++)
{
attackAnim = animation.PlayQueued(arrMeleAttacks[attackCntr],QueueMode.CompleteOthers);
attackAnim.speed = attackAnim.length * AttackSpeed;
yieldTime += attackAnim.length;
}
TotalAttackTime = yieldTime;
yield return new WaitForSeconds(yieldTime);
}
if(_isAttacking)
{
attackTime+=Time.deltaTime;
//Play Current Attack
//PlayAttackSequence();
StartCoroutine("PlayAttackSequence");
if(attackTime>=TotalAttackTime){
_isAttacking=false;
attackTime=0;
TotalAttackTime = 0;
}
}