Animation finish completely?

Ive animated my gun so it has a sprint animation and then scripted that when shift is held down it plays and when let go off it stops. But when I let go of shift the animation stops where ever it is in the animation, instead of finishing the animation completely. How can I change my script so if shift has stopped being pressed it finishes the animation completely and leaves it in the starting position?

function Start () {

animation["gun run"].speed = 2;
animation["gun run"].wrapMode = WrapMode.Loop;

}


function Update () {

if(Input.GetKeyDown("left shift")){
  animation.Play("gun run");
}

if(Input.GetKeyUp("left shift")){
  animation.Stop("gun run");
}
}
animation["gun run"].wrapMode = WrapMode.Once;

instead of Stop()

not tested

you can use animation.Crossfade instead of animation.play that might work…

The solution of your problem Blink can be a timer. You basically create a Timer that his length is equal to the sprint animation and you initiate it before the animation.play. You add an and comparison operator in the if statement that said : “if the Timer is equal to 0” then you can animation.Stop.

Best Regards,
Nb1