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