addition animation

Hi

I found this scipt from another answer

 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;
    }
}

I am trying to add 3 attacks in this script so they play the animation how would i do that like shoot and throw granade and play animation for pickup each time i try to change it but it messes up my animation. I want it to be able to play grenade throw animation when i press 1 and pickup item by 2 and mouse click to play the animation for shoot this was one my try on trying to get this work

var running= false;
var shoot= false;
var idle = true;
var pickallow;
var throwing= false;

function Update () 
{ 
    if (Input.GetAxis("Vertical") > 0.2 && !running) 
{
        animation.CrossFade ("run");
        running = true;
shoot = false;
idle = false;

    } 

    if (Input.GetAxis("Vertical") <= 0.2 && running)
 {       animation.CrossFade ("idle");
       running = false;
shoot = false;
idle = true;

    }

if (Input.GetAxis("Vertical") <= 0.2 && "fire1")
{
animation.CrossFade ("shoot");
        shoot = true;
running = false;
idle = false;

}

if (Input.GetAxis("Vertical") <= 0.2 && Input.GetKeyDown( "1") == true)
{
animation.CrossFade ("throw");
        throwing = true;
        running = false;
idle = false;
shoot = false;   

}
}

please help thanks

Your script isn't going to get you the results that you want. The final result you want is probably going to involve things like animation layers and blending and so forth. Be sure to read the character animation documentation

If you want a working example of a complex system of animations, check out the 3rd person shooter demo project. If you want something a little simpler, look at the 3D platform game demo project