- Home /
              This question was 
             closed Oct 20, 2015 at 02:32 PM by 
             DrGreenthumbs92 for the following reason: 
             
 
            Solved it, I was attaching the animation controller rather than the animation its self
 
               Question by 
               DrGreenthumbs92 · Oct 19, 2015 at 08:47 PM · 
                animationjavascriptontriggerenter  
              
 
              I cant get my animation to trigger.
So I have an empty game object with a box collider with is trigger checked and the script attached, a child of that is the object I have animated (a gate sliding across). As it stands when the player walks into the collider nothing happens and the console gives these 2 errors: Invalid Layer Index '-1' UnityEngine.Animator:Play(String)
and
Animator.GotoState: State could not be found UnityEngine.Animator:Play(String)
My js is:
 #pragma strict
 
 var Floor_Gate : GameObject; //The name of the animated object
 
 function OnTriggerEnter(Other : Collider){
  
     if(Other.gameObject.tag == "Player"){
         Floor_Gate.GetComponent.<Animator>().Play("FloorGate");
     }
 }
               Comment
              
 
               
               koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                