Play animation when 2 keys pressed?

i thought it would be:

{

if(Input.GetButton("w") && Input.GetButtonDown("space") { 
    animation.Play("JumpOver") 
}

}

but that does not appear to work :confused:
any ideas?

This is a walk script that i made
#pragma strict

function Start () {

}

function Update () {
    if (Input.GetKey(KeyCode.W))
    animation.Play("Walk");
    if  (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.W))
    animation.Play("Sprint");
}

this shall Help

Theoretically this is should be working, but there are two issues:

  1. You’re using GetButton/GetButtonDown, so you need to use buttons defined in the Input Manager
  2. You are using GetButtonDown in one of them and that is only true for one frame. You would have to make sure, that you press ‘w’ first and ‘space’ second.

if(Input.GetButton(“w”) && Input.GetButtonDown(“space”)) {
animation.Play(“JumpOver”)
}

//Add a bracket after space