Play animation without holding the key (415442)

Hi, i want to play a animation on my character and it’s work fine. But i have to hold the key while the animation play. If i just press the key, the animation stop. Can you help me.

if(Input.GetButtonDown(“ADN”))
{ SendMessage(“ADNdrain”);}

Function ADNdrain
{
animation.CrossFade(“ADNdrain”);
}

this is the code that me and my class used throughout a project pretty much, u press the button, it tells the function to start playing.

we created a function that would play the animation instead of just using like you did but that was because we went off of the 2d platformer tutorial and they had it that way so we just kept our structure the same. So just create a new function named whatever and make it SendMessage (“whatevername”) then tell it to play in the function

if that doesn’t work u could try changing animation.CrossFade to animation.Play

Thanks, but that’s not work. It’s the same problem, the animation stop if we not press the key.

Did you try animation.Play?

and do you have the input.GetButtonDown in function Update?

Also how do you have the animation wrapped and everything?

You might want to use Input.GetButtonUp instead?

Ok thanks i found my problem.

What was your problem?
I’m having the same problem. I want to have my character crouch when I hit GetButtonDown. (One button press and it crouches). But I only get like 3 frames of animation!!!