- Home /
Wierd Animation Bug
Okay so when I'm working on my sprint animation, I add a key frame, get the angle and position of the gun right, and everything works. However, when another key frame is added, the gun disappears and I cannot recover it until I remove the key frames and stop recording. I'm also getting an error in the console that says "Array index out of range." Please Help. Here is my only code so far:
var PlayerState : float; var PlayerAnimSec : GameObject;
function Update () {
PlayerStateController();
PlayerAnims();
}
function PlayerStateController() { if ((Input.GetAxis("Vertical") !=0 || Input.GetAxis("Horizontal") !=0))
{ if (Input.GetButton("Sprint")) { PlayerState = 2; } else { PlayerState = 1; }
} else { PlayerState = 0; }
}
function PlayerAnims() { if (PlayerState == 0) { PlayerAnimSec.animation.CrossFade("Idle Animation", 0.4); } else if (PlayerState == 1) { PlayerAnimSec.animation.CrossFade("Walking Animation", 0.4); } else if (PlayerState == 2) { PlayerAnimSec.animation.CrossFade("Sprint Animation", 0.4); } }
Your answer
Follow this Question
Related Questions
Array index is out of Range!? 1 Answer
Random object, Array index out of range 0 Answers
array problem index out of range ? why ? 2 Answers
C# - IndexOutOfRangeException - Array index is out of range 2 Answers
Array out of its own range? 4 Answers