Hey guys
I have problem with my IEnumerator function.
It should play the animation and move the player,
so long the player is not reaching his end position and the animation is not finished.
It works perfekt when I only query the endPos, but the query with the animation length wont work
The currentStateName and Phase is set before calling the IEnumerator (Thats not the problem ^^)
Here is my code:
AnimatorStateInfo currentState;
string currentStateName;
int currentStatePhase;
float currentStateTime;
float animationTimer;
IEnumerator WaitForAnimation ()
{
currentStateTime = currentState.length;
do
{
Moving();
animationTimer = animationTimer + Time.deltaTime;
animator.SetInteger (currentStateName, currentStatePhase);
yield return null;
}while (transform.position != EndPos || animationTimer < currentStateTime);
//Happens when reached attackEndPos and animation finished
animationTimer = 0;
animator.SetInteger (currentStateName, 0);
}
Thank you so much for your time!
EDIT:
Edited the && condition to || but it still don’t work