x


Animation.Play(useVar)

Before i talk about this, take a look below and also error log.

Code:

//FOR ANIMATION
static var leveldiff : String = "lv1easy";
private var num001;
private var num002;
private var num003;
private var num004;
private var num005;
var enemystartonce : boolean = true;

//ANIMATION LIST:
// Level 1 EASY
var lv1easy;
var lv1easy001 : AnimationClip;
var lv1easy002 : AnimationClip;
var lv1easy003 : AnimationClip;
var lv1easy004 : AnimationClip;
var lv1easy005 : AnimationClip;



function randomanim() {
    var randomanimation : int = Random.Range(1,5);
    print(randomanimation);



    if (leveldiff == lv1easy) //Level 1 Easy
    {
        num001 = lv1easy001;
        num002 = lv1easy002;
        num003 = lv1easy003;
        num004 = lv1easy004;
        num005 = lv1easy005;
        return;
    }


    //START ONCE!
    if (enemystartonce == true) {
        enemystartonce = false;
        animation.Play(num001);
        return;
    }

    yield WaitForSeconds(animation.clip.length);

    //START RANDOM ANIMATION
    if (randomanimation == 1)
    {
        animation.Play(num001);
        return;
    }
    else if (randomanimation == 2)
    {
        animation.Play(num002);
        return;
    }
    else if (randomanimation == 3)
    {
        animation.Play(num003);
        return;
    }
    else if (randomanimation == 4)
    {
        animation.Play(num004);
        return;
    }
    else if (randomanimation == 5)
    {
        animation.Play(num005);
        return;
    }

}

Unity Error said that "The animation state could not be played because it couldn't be found! Please attach an animation clip with the name '' or call this function only for existing animations."


I want to make it random play animation per each level and difficulty level and make "animation.play()"

Thanks.

more ▼

asked Nov 18 '10 at 01:08 PM

alienx2 gravatar image

alienx2
76 5 5 12

bump... no answer?

Nov 19 '10 at 08:33 AM alienx2

do you have a default animation attached to your object?

Nov 22 '10 at 01:14 AM daviddan2010
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5653
x1209
x133
x110

asked: Nov 18 '10 at 01:08 PM

Seen: 2080 times

Last Updated: Nov 18 '10 at 01:08 PM