- Home /
 
               Question by 
               PureSirGold1 · Dec 22, 2014 at 04:19 PM · 
                2danimator2d animation  
              
 
              Unity Animator transition on collision
So I have a chairlift with box colliders moving towards a character with an Animation controller and I have a sit animation state attached to it when it touches the chair. I set the transition from idle to sit and made the condition for it : ShouldSit = true
then I add a script to my character the problem is that when the chair touches the character he doesn't sit!
 var anim : Animator;
 function Start () {
     anim = GetComponent("Animator");
 }
 
 function OnCollisionEnter (col : Collision)
 {
     if(col.gameObject.name == "kedute")
     {
         anim.SetBool("ShouldSit",true);
     }
 }
what have i done wrong? Is there a better way to do this ?
               Comment
              
 
               
              The learn section is your friend. http://unity3d.com/learn/tutorials/modules/beginner/animation
Its not just there but what is actually inside your animation controller that counts.
Hey , thanks for the help , the problem was that I was using OnCollisionEnter in 2D game I should have used OnCollisionEnter2D
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                