how to fix this script

hey guys i have a problem with the jump action
when i press button Jump my character jumps but its jump animation does not finish.
the animation has to play once each time i press Jump

i know its no pro script but i am a biginner with programming
thanks guys

var minimumRunSpeed = 1.0;

function Start () {

	// Set all animations to loop

	animation.wrapMode = WrapMode.Loop;



	// Except our action animations, Dont loop those

	animation["shoot"].wrapMode = WrapMode.Once;

    animation["jump"].wrapMode = WrapMode.Once;	

	// Put idle and run in a lower layer. They will only animate if our action animations are not playing

	animation["idle"].layer = -1;

	animation["walk"].layer = -1;

	animation["run"].layer = -1;

	

	animation.Stop();

}animation["jump"].wrapMode = WrapMode.Once;	



function SetSpeed (speed : float) {

	if (speed > minimumRunSpeed)

		animation.CrossFade("walk");

	else

		animation.CrossFade("idle");



	if (speed > minimumRunSpeed)

		animation.CrossFade("jump");

	else

		animation.CrossFade("idle");

}



function Update() {

if( Input.GetKey( "w" ) )

{

animation.Play("walk");

}

if( Input.GetKeyUp( "w" ) )

{

animation.Stop("walk");

animation.Play("idle");

}

if( Input.GetKey( "s" ) )

{

animation.Play("walk2");

}

if( Input.GetKeyUp( "s" ) )

{

animation.Stop("walk2");

animation.Play("idle");

}

if (Input.GetButton ("Jump")) {

animation["jump"].wrapMode = WrapMode.Once;	

animation.Play("jump");

if (animation.Play("jump")= false;

    animation.Play("idle") = true;

    }

}

if (animation.Play(“jump”)= false;

    animation.Play("idle") = true;

    }

you’re missing a conditional for this if statement. these aren’t valid statements that i’m aware of. if you’re checking whether an animation is already playing look at the isPlaying variable and the IsPlaying method. also don’t use ‘=’ if ur trying to make a comparison…use ‘==’. some languages let u set values within the if statement. so you could be setting a value with ‘=’ rather than just making a comparison with ‘==’. that statement should look more like

if(!animation.IsPlaying("jump"))
    animation.Play("idle");

http://docs.unity3d.com/Documentation/ScriptReference/Animation.IsPlaying.html

as far as why the jump animation stops…i would check to make sure no other animations are scripted to play. like maybe an ‘idle’ animation is triggered before the ‘jump’ animation is done. it could be a number of things. you’ll just have to isolate the issue. have u tried commenting out all animation commands except the jump? clear the script and just have the jump animation triggered to play and see what happens. if the whole jump plays after commenting everything out, then it must be a logical mistake in ur scripts; otherwise it’s a mistake with the animation or importing.

also, it might not be necessary to stop an animation before u play another one. so instead of stopping the walking animation to play the idle animation, just try playing the idle animation and any other animation will cease.