Walking animation problem.

hey guys i have a question here.

I Made an animation so that when i’m walking with my gun the gun moves up and down and it’s good but i have an problem.

When i stop walking the gun keeps on making the animation, here’s my script :

   function Update()
{
 if(Input.GetKeyDown("w"))
 {
  // Plays the walking animation - stops all other animations
  animation.Play("walking", PlayMode.StopAll);
 }
}

Does anyone know how to make it so that it stops when i stop pressing w?

I’ve heard about making it idle, making a new animation and then doing the same thing putting it in the weapon with another script blabla. But when i do that in the code should i do it like this? :

   function Update()
{
 if(Input.GetKeyDown(""))   // <---- NOTICE I PUT NOTHING BETWEEN THE "" 
 {
  // Plays the idle animation - stops all other animations
  animation.Play("idleanimation", PlayMode.StopAll);
 }
}

Thanks.

[ Javascript please. ]

  • Vince

function Update()
{
if(Input.GetKey(“w”))
{
animation.Crossfade(“walking”);
}
else
{
animation.Crossfade(“idle”);
}
}