- Home /
Question by
dsdsds123100 · May 23, 2012 at 10:00 PM ·
animation
need help Animation script
Im trying to add a idle Animation Butt wen i do it just overrides the other animation
function Update () {
var forward = Input.GetKey(KeyCode.W); var run = Input.GetKey(KeyCode.LeftShift) && (KeyCode.W);
if(forward){
animation.CrossFade("walk");
transform.Translate(0 ,0 , Input.GetAxis("Vertical") * 0.10);
}
if(run){
animation.CrossFade("run");
transform.Translate(0 ,0 , Input.GetAxis("Vertical") * 0.20);
}
else{
animation.CrossFade("idle");
}
}
Comment
Answer by whydoidoit · May 24, 2012 at 12:42 AM
You are missing an "else" in front of if(run) so if you are not running, you are idling.
Your answer
![](https://koobas.hobune.stream/wayback/20220613071848im_/https://answers.unity.com/themes/thub/images/avi.jpg)
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