need help in key press

i want to stop the animation once i release out pressing the “q” button… I really need your help guys… :slight_smile:

this is my code…

function Update ()
{
if (Input.GetKey(“q”) )
animation.CrossFade (“run”);
animation[“run”].wrapMode = WrapMode.Loop;

}

Input.GetKeyDown and Input.GetKeyUp?

As written, the CrossFade code is only called when “q” is pressed, and the wrapMode setting is always set each update.
Depending on your intention you may need to add some brackets to your “if” statement.

function Update () 
{ 
if (Input.GetKey("q") ) {
animation.CrossFade ("run"); 
animation["run"].wrapMode = WrapMode.Loop; 
} else {
animation.Stop();
}

__

thank you guys! ill try those codes when i arrive at home… :0