animating character

hi guys

unity animation script is not working for me can someone help. when i attach this to my char nothing happens but when i remove it, it plays all of them at once. I need a script in which i can drop my animation files into and it can play it accordingly

function Update ()
{
   if (Input.GetAxis("Vertical") > 0.2)
       animation.CrossFade ("walk");
   else
      animation.CrossFade ("idle");
} 

all help would be good. I had to spend several days to bring the animation in and now i am stuck at this

please help

It's probably because you're repeatedly triggering the crossfade every frame, rather than just at the single moment when the animation should change.

You need to add some extra code which checks whether the input state has changed from what it was last frame, and only if it's changed, do the CrossFade. In the example below, a boolean variable (true/false) is used to check whether the state has already been changed.

Eg:

var walking = false;

function Update () { 
    if (Input.GetAxis("Vertical") > 0.2 && !walking) {
        animation.CrossFade ("walk");
        walking = true;
    } 

    if (Input.GetAxis("Vertical") <= 0.2 && walking) {
        animation.CrossFade ("idle");
        walking = false;
    }
}