Using multiple buttons in script

Hi,
I have a script called “Actions” that looks like this:

#pragma strict

function Start () {

}

function Update () {
if (Input.GetAxis("Vertical")){
animation.CrossFade("Walk_");
}

else if (Input.GetAxis("Horizontal")){
animation.CrossFade("Walk_");
}

else if (Input.GetButton("Scratch")){
animation.CrossFade("Slash");
}

else if (Input.GetButton("Bite")){
animation.CrossFade("Bite");
}

else if (Input.GetButton("Swat")){
animation.CrossFade("Wing_Swat");
}

else
animation.CrossFade("Rest");
}

I have also added a Third Person Controller Script. I had to put the walk animations and idle animation into my “Actions” script so that the action script wouldn’t stop those animations from playing. Now, my question is, how would I add a run animation into my script so that that animation wouldn’t be overrode as well?

The Actions Script seems to stop the animations in the Third Person Controller script except for the idle animation. The way I have coped with this is by those same animations into the Actions script. It has worked fine, but with a run animation I would need to be able to press the ‘shift’ key and the forward key at the same time to run.

How would I script the usage of two keys at once in my actions script for the run animation?

If this is confusing, ask me to explain more clearly.

Thanks!

I don’t know if i quite understood your problem but does this work for you:

    function Update () {
     ...
        else if (Input.GetAxis("Vertical")){
          if(Input.GetAxis("Vertical")>0 && Input.GetButton("Run")){
            animation.CrossFade("Run_");
          }else
            animation.CrossFade("Walk_");
        }
    ....

Why are the buttons named, Bite and Scratch? You probably need to provide us with more information.

Ok. I think you should try this:

function Update() {
    
      if (Input.GetButtonDown("Sprint") && (Input.GetButtonDown("Vertical") || Input.GetButtonDown("Horizontal"))) {
    
          animation.CrossFade("Run_");
    }
}