Howdy,
There has been a problem in my game for about two weeks now and it has been driving me insane. I have a BasicAnimations javascript I wrote that is supposed to play a walking animation when walking, and two jumping animations, one after another, when jumping. The problem is that when I’m doing a running jump, none of the animations play when the jumping animations are supposed to play. When I’m not doing a running jump and just jumping up and down, the jumping animations play regularly. Like I’ve said, I’ve been studying this script for two weeks, and I still don’t know how to solve it. I know it has something to do with the jumping animations and walking animation playing at the same time, but I’m not sure how to fix it. I’ve tried everything, and I am tearing my hair out. Thanks.
#pragma strict
var grounded : boolean;
grounded = true;
function Update () {
if (Input.GetAxis("Horizontal") && grounded == true) {
animation.Play("walk");
}
if (Input.GetAxis("Vertical") && grounded == true) {
animation.Play("walk");
}
if (Input.GetButtonDown("Jump") && grounded == true) {
grounded = false;
animation.Play("jump start", PlayMode.StopAll);
animation.PlayQueued("jump end", QueueMode.CompleteOthers);
}
if (grounded == false) {
animation.Stop("walk");
grounded = true;
}
}