Question by 
               Oposow · Jul 16, 2017 at 07:49 PM · 
                animationanimatoranimator controller  
              
 
              Animator doesn't change animation in Update() function
Hi,
I'm trying to change animation using Animator object and transitions. However nothing happens after changing value of parameters or setting triggers. Here is my code:
 private Animator animator;
 private int lastSpeed
 void Start()
 {
     animator = GetComponent<Animator>();
 }
 void Update()
 {
     if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
     {
         Speed = 2;
    }
     if (lastSpeed != Speed)
     {
             lastSpeed = Speed;
             animator.SetInteger("Speed", Speed);
      }
     if (Input.GetMouseButtonDown(0))
     {
         animator.SetTrigger("Attack");
     }
And animator is still playing Idling animation which is played when Speed equals '0'. However value of parameter and trigger state are changed in animator in Play Mode.
The most suprising thing for me is fact, that if is set "Speed" value in Start() function animator playes correct animation. That's why i suppose everything in transitions and animations is correct. Also animator playes animations when I invoke
     animator.Play("animationName");
Does anyone knows what is the reason why animations are not played after setting values in Update() or LateUpdate() function?
Thanks in advance!
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                