- Home /
IndexOutOfRangeException: Array index is out of range. UnityEditor.AnimationSelection.GetClipAtIndex
Hey guys, so i get this error. the problem is i dont use any of the animations in teh animation array of the animation component. I have duplicated and moved them to another folder to set the loops and stuff. Why this happens?
Answer by orktech · Apr 21, 2013 at 09:22 AM
Unity probably lost references to Animations for your GameObject. In Hierarchy choose your animated gameObject-> then in Inspector look in Animation section -> Animations lis. Check if all animations in that list refer to something and not "None", and size of the animation array.
The answer to your question would also be - uncheck "Play automatically" in that section. If you decide not to use animations at all, remove Animations component I hope I helped somehow
thank you, the second advice fixed it, but there is still a weird problem. On runtime the animated model (enemy) walks normally to me and in the inspector i can see the active animation to be the "run" animation but the model doesnt animate. Namely the active animation is correct, but it doesnt play it, or plays it with late. Whats the possible reasons?
I had the same issues. In your script on Start() try setting
animation.wrap$$anonymous$$ode = Wrap$$anonymous$$ode.Loop; animation.Stop(); animation.Play();
somehow it fixes my problems. Also make sure that in Animation section in Inspector you set default animation as well Another thing is your animation is probably over (played once) and its Wrap$$anonymous$$ode was PlayOnce. $$anonymous$$ake sure you set another animation when previous is over. Set Animation wrap modes correctly for run (Loop), attack (PlayOnce) etc. Good luck
Well, i use this in update:
if(!gameObject.GetComponent().isPlaying){ gameObject.GetComponent().clip.name);
}
I think it does the same job right?
gameObject.GetComponent().isPlaying WRONG your gameobject already has animation variable - that is use just
animation.clip.name animation.isPlaying()
Your answer
![](https://koobas.hobune.stream/wayback/20220613100734im_/https://answers.unity.com/themes/thub/images/avi.jpg)