- Home /
Question by
DrakeDiablo · Apr 23, 2014 at 11:01 PM ·
animationcrashes
Unity crashes when I add a script!
I made a simple animation script that when you press a button an animation plays. When I apply it to any object, and play the game, unity crashes!! If I delete the script then everything works fine.
The script goes like this.
if(Input.GetKey("w"){ animation.Play("Run"); } else{ animation.Stop(); }
Comment
Can you write the full script or at least explain it better...
Probably not related be there is a parenthesis missing in your if()
.
Answer by 0V3RR1D3 · May 01, 2014 at 04:53 AM
This is becuase you are running an animtion once per frame, do:
if(Input.GetKeyDown("w")){ animation.Play("Run"); }
Your answer
![](https://koobas.hobune.stream/wayback/20220613143435im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Trigger door animation with external trigger 1 Answer
what's wrong with this script? 2 Answers
A node in a childnode? 1 Answer
How to get an animation script working? 1 Answer
Animation Not Playing 1 Answer