- Home /
The question is answered, right answer was accepted
Run Sprint animation and stop it when button is released
I have this script and it works perfectly, but when you release the left shift it still runs the animation
function Update () {
if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.W))
animation.Play("ANIMATION_NAME");
}
Also, how can I get it to increase speed, too?
Answer by Jeff-Kesselman · May 25, 2014 at 06:36 PM
You are re-running the animation every frame. So when you release the key its still going to run for at least one cycle. If it is doing more then that, is it possible you have the animation set to loop?
As for increasing speed, the best way is to have a walk animation and a separate run animation at max speed and use animation blending for the points in-between.
Follow this Question
Related Questions
Animation problem in script 0 Answers
Animation can't find my animations 1 Answer
problem not playing animation on keyDown 2 Answers
Play Animation With GetKey 1 Answer