Question by 
               sir_ver · Jan 13, 2019 at 09:26 AM · 
                animationscripting problemanimatorplayergetcomponent  
              
 
              How to call Animator from another script
Hey I have a diying animation but it's not played by the script. This is my code:
     static Animator anim;
     GameManager instanceGM;
 
     private void Awake()
     {
         instanceGM = GameManager.instance;
         agent = EnemyController.instance;
 
         anim = instanceGM.player.GetComponent<Animator>();
     }
     void OnTriggerEnter(Collider col)
     {
 
             //Debug.Log(col.gameObject.tag);
         if (col.gameObject.CompareTag("player"))
         {
             Debug.Log("Player died");
             anim.SetBool("isDead", true);
             StartCoroutine("WaitForAnim");
             
         }
 }
 IEnumerator WaitForAnim()
 {
 while (true)
 {
     instanceGM.player.GetComponent<BoxCollider>().enabled = false;
     yield return new WaitForSeconds(2);
     instanceGM.player.GetComponent<BoxCollider>().enabled = true;
 }
 }
And this is the GameManager:
 public GameObject player;
 public static GameManager instance;
     private void Awake()
     {
         //instances for variables
         instance = this;
     }
Do you know what I am doing wrong?
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Variety of animation and meshes. 0 Answers
How to create transitions in the animator without creating a disaster? (Layers?) 0 Answers
animation scirpting 1 Answer
How do I add animation to my script? 1 Answer
Confused about animations 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                