[ask] ienumerator not work

i have a simple script for play the animation.
but i still not know why my code doesn’t works.

can you help me? this is my code :

int i = 1;
	Animator anim;
	// Use this for initialization
	void Start () {
		
		anim = GetComponent<Animator> ();
		StartCoroutine (animation1());
	}

	IEnumerator animation1(){
		while(i==10){
			anim.Play ("idle awal");
			yield return new WaitForSeconds (2.5f);
			anim.Play ("obstacle");
			yield return new WaitForSeconds (1f);
			anim.Play ("obstacle out");
			yield return new WaitForSeconds (4.5f);
			i--;
		}
	}

please help me :frowning:

while(i==10)

i is 1 at the beginning, so the loop is never entered.

Try something like this:

IEnumerator animation1()
{
  i = 10;
  while( i>0 )
  {
    anim.Play ("idle awal");
    yield return new WaitForSeconds (2.5f);
    anim.Play ("obstacle");
    yield return new WaitForSeconds (1f);
    anim.Play ("obstacle out");
    yield return new WaitForSeconds (4.5f);
    i--;
  }
}