animation - Unity 5.1 Animator Controller not transitioning -


i have created animator controller (called player) , assigned animator field of humanoid avatar, simple animation states suitable transitions. please see 2 attached images.

i have attached script, containing following code, avatar game object, wonder missing or doing wrong transition idle walk not take place, though can see speed variable increases when press w.

could please me understand problem?

using unityengine; using system.collections;  public class charanim : monobehaviour {     private animator animator;     float speed;      void start()     {         animator = getcomponent<animator>();     }      void update()     {           animator.setfloat( "speed", input.getaxis("vertical") );        if ( input.getkeydown( keycode.w ) && ( speed > 0.5f ) )        {           animator.settrigger("walk");       }       else        {           animator.settrigger("idle");       }     } } 

x

enter image description here

enter image description here

the problem in code is, animator.settrigger("walk"); gets called in single frame when pressed key , animator.settrigger("idle"); gets called rest of frames.

try changing input.getkeydown( keycode.w ) input.getkey( keycode.w ). former returns true once, instant when press down key, whereas latter returns true until release key. :

void update () {     if(input.getkey(keycode.w))     {         animator.settrigger("walk");     }     else                     animator.settrigger("idle"); } 

on side note, don't need speed variable in animator trigger walk animation, since doing using w.

animator setup

idle -> walk enter image description here

walk -> idle enter image description here


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -