I added an Animation component to a gameobject, then set the size of animations to 3, then assigned the animation clips to the 3 slots.
–. First I try to access the animations this way,
public Animation[] anim;
anim = gameObject.GetComponents<Animation>();
anim[0].Play();
anim[1].Play();
But I will get error when it reaches anim[1]
IndexOutOfRangeException: Index was outside the bounds of the array.
I guess I can’t access their array?
–. Then I tried to build my own array
public Animation[] anim;
Then set the anim size to 3 in inspector, I’m UNABLE to assign animation clips to the slots in script component…
–. Lastly I tried access animation clip by it’s name: “Armature|idle01”,etc.
gameObject.GetComponent<Animation>().Play("Armature|idle01");
I get error:
The animation state Armature|idle01 could not be played because it couldn’t be found!
Please attach an animation clip with the name ‘Armature|idle01’ or call this function only for existing animations.
I’m seriously confused.