- Home /
Question by
Red Sentinel · Jun 05, 2013 at 06:03 AM ·
animationjavascript
Play Animation on Button Down
Hi everyone. I've been trying to get a specific animation to play when the player presses w, a, s or d. Whenever I press w, a, s or d though, nothing happens. This is what I have already. Could anyone tell me what's wrong?
var ForwardAnimation : Animation;
var BackwardAnimation : Animation;
var RightAnimation : Animation;
var LeftAnimation : Animation;
function Start () {
}
function Update () {
if (Input.GetButtonDown ("w")){
animation.Play("ForwardAnimation");
}
if (Input.GetButtonDown ("s")){
animation.Play("BackwardAnimation");
}
if (Input.GetButtonDown ("d")){
animation.Play("RightAnimation");
}
if (Input.GetButtonDown ("a")){
animation.Play("LeftAnimation");
}
}
Comment
Best Answer
Answer by TheRichardGamer · Jun 05, 2013 at 07:20 AM
Put a else statement between every if(Input) and it should work :)
Your answer
Follow this Question
Related Questions
Animation play when dead 2 Answers
animation.Play isn't working 1 Answer
Can I make animations snap to a frame? 1 Answer
Scripting "If only" functions? 2 Answers
How would you reccommend adding the jumping animation to my script? 0 Answers