- Home /
Animation Script Help
Hi! Here is my animation script--->
function Update () {
if (Input.GetButton("Jump"))
animation.CrossFade ("Jump");
else
animation.CrossFade ("Walk");
}
It works really well, but my problem with it is that it plays as long as you have the jump button pushed down. I would like it so that you just press the button once and the animation plays till it's done. How would I do that? Do I need an extra line of code? Thanks for reading! -Rov
Answer by perchik · Jul 24, 2012 at 06:24 PM
You probably want to use GetButtonUp instead of just GetButton, that way it's only called when the button is released.
Once I replace GetButton with GetButtonUP the animation doesn't play. Am I doing something wrong? Thanks for replying!
-Rov
GetButtonUp would only let them jump after the key is released.
Rovalin. You could go a few routes. Reference "WaitForAnimation" and "animation.isPlaying". Good ways to manipulate when the animation plays.
you could also add in a bool to turn off the keystroke ability while once the animation has started, and then turn it back on when it is finished.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Play animation once 1 Answer
Play animation for horizontal and vertical movement? 1 Answer
Mixamo Call Animation from Script 0 Answers
Adding animation clips via script 2 Answers