Animation

Please.
my animation doenst function.
if i press button Q, my animation dosnt start,
i dont now why but i need help on my script!

#pragma strict
var Projetil : GameObject;

function Start () {

}

function Update () {
    if(Input.GetKeyUp(KeyCode.Q))
    {
       
       
            if(Magics.m6==1)
            {
                if(Attributes._mp>=5)
                {   
                        pera();
                        AnimationHi._animation=3;
                        Instantiate(Projetil,transform.position,transform.rotation);
                        Attributes._mp-=5;
               
                   
                }
             }   
       
        }

}
function pera(){
yield WaitForSeconds (GetComponent.<Animation>().clip.length);
}

anybody cam help me?

Add in debug.logs to every conditional to find out where exactly this is getting stopped. Check the code immediately after the last debug.log that’s firing and check it closely for any sort of problems.

This is the fundamental way that people go about debugging their own code. In this case though, I’ll give you a hint: where exactly are you using Animation.Play in this script?

EDIT: Wait patiently for help to come, do not bump 12 minute old posts.

ok

thanks!

i found in unity forums one example
like that
(but this doenst function)
whats the problem?

#pragma strict
var Projetil : GameObject;
var anim: Animation;

function Start () {
    anim = GetComponent.<Animation>();
    anim.Play(anim.clip.name);
}

function Update () {
    if(Input.GetKeyUp(KeyCode.Q))
    {
       
       
            if(Magics.m6==1)
            {
                if(Attributes._mp>=5)
                {   
                        pera();
                        AnimationHi._animation=2;
                        Instantiate(Projetil,transform.position,transform.rotation);
                        Attributes._mp-=5;
               
                   
                }
             }   
       
        }

}
function pera(){
yield WaitForSeconds (anim.clip.length);
}

Where’s you debug logs?

And if you’re expecting that pressing Q should play the animation, then Animation.Play should probably be in the conditional statement for “pressing Q” right? Cause and effect- how’s it supposed to know when to play? You have to tell it. If you put “play” in the Start, then it’s going to play on start, but that’s all, because that’s the only place you have “play”, right?

i dont understand
exactly you.
i only need put the AnimationHi._animation=2
in the start???

1: Unity - Scripting API: Debug.Log

I’m no longer responding until you put Debug.Logs every 2 lines in your code and can tell me, with certainty, how far it’s getting when you press Q. I’m getting tired of mentioning it in every thread you post and receiving no response.

2: I have absolutely no idea what AnimationHi is, because it’s not defined in this code snipped you’ve posted. I’m pretty confident that whatever it is, however, that it isn’t running Animation.Play. If you want an animation to Play, you need to actually PLAY IT.

ok
i have a other idea to start my animation
thanks for responding.
the animation has been completed!