Error : Animator has not been initialized. UnityEngine.Animator:SetBool(String, Boolean)

I notice my animation on my enemy ai wasn’t working . It only idles . I look at the console and I saw this error : Animator has not been initialized.

UnityEngine.Animator:SetBool(String, Boolean)

Enemyai:Update() (at Assets/Enemyai.cs:40)

I need to change something on line 40 . I used this same script on a another enemy ai . Here is my script :

 using UnityEngine;
 using System.Collections;
 
 public class Enemyai : MonoBehaviour {
 public Transform player;
 static Animator anim;
     void Start () 
     {
             anim = GetComponent<Animator> ();
     }
     
 
     void Update () 
     {
         if (Vector3.Distance(player.position, this.transform.position) < 10)
         {
             Vector3 direction = player.position - this.transform.position;
             direction.y = 0;
             
             this.transform.rotation = Quaternion.Slerp (this.transform.rotation,Quaternion.LookRotation(direction), 0.1f);
			 
			 anim.SetBool("isIdle",false);
             if(direction.magnitude > 2.6 )
             {
                 this.transform.Translate(0,0,0.05f);
                 anim.SetBool("isMoving",true);
                 anim.SetBool("isAttacking",false);
                 }
			 else
             {
                 anim.SetBool("isAttacking",true);
                 anim.SetBool("isMoving",false);
                 
             }
         }
        else
        {
            anim.SetBool("isIdle",true);
            anim.SetBool("isMoving",false);
            anim.SetBool("isAttacking",false);
            
        }
     
     
     }
 }

http://answers.unity3d.com/answers/1110051/view.html