How to Properly and Effectively Script Animation for Several Inputs.

For some reason when i try to use this code in game, it only plays the animations for Axis' "AA" and "DD" and Ive been working on it for hours and i cant see to fix that issue, can anyone help?

function Update (){

if (Input.GetAxis("WW"))
    animation.CrossFade("WMotion");

if (Input.GetAxis("SS"))
    animation.CrossFade("SMotion");

if (Input.GetAxis("AA"))
    animation.CrossFade("AMotion");

if (Input.GetAxis("DD"))
    animation.CrossFade("DMotion");

if (Input.GetButtonDown ("Fire1"))
    animation.CrossFade("SWswing");

}

All Help is greatly appreciated!

`Input.GetAxis` returns a float, thus your if-s should always return `true` because there is a value returned. I think you might need something like this:

if(Input.GetAxis("Vertical") > 0)
  animation.CrossFade("WMotion");
else
if (Input.GetAxis("Vertical") < 0)
  animation.CrossFade("SMotion");
if(Input.GetAxis("Horizontal") > 0)
  animation.CrossFade("DMotion");
else
if(Input.GetAxis("Horizontal") < 0)
  animation.CrossFade("AMotion");

It seems like you want something like an animation control, so this might be a solution.

On the other hand, if you want buttons to control (WASD just to toggle the animations), you should use `Input.GetButtonDown` like you did for the Fire button.