int array examples not helping very much
why does every example of arrays show how to do it so you can print out numbers. Pretty useless. Who makes a game printing out numbers. How about an example of something real like playing an array of sounds or an array of animation? I try to adapt these int examples to play animation but it doesn't work. I know how t play sound arrays so took one of those scripts and adapted for animation but it doesn't work. can anyone tell me why this doesn't work? it looks as though it is trying to play all the animations in the array at once public AnimationClip[] enemyAttack;
public void Attack() {
animation.clip = enemyAttack[Random.Range(0, enemyAttack.Length)];
animation.Play();
Could you paste in the entire script? This small sample doesn't help much. From this small chunk of script it looks like you are assigning animation.clip, but trying to play the entire animation array. Try animation.clip.Play(). I could be wrong, but it's very hard to tell with this small sample.
This isn't enough information. what error are you getting? what's not working exactly? is it telling you your array is empty, is it just not playing, is the wrong animation playing, etc... we need more info.
Your answer
Follow this Question
Related Questions
Play animation on collision 1 Answer
I cannot drag the animations into inspector please help [code snippet included] [C#] 0 Answers
stopping the game and show an animation to user for the points 1 Answer
Cannot apply indexing with [] to an expression of type 'Animator' 1 Answer
Enemy Animation Play 0 Answers