2
\$\begingroup\$

Is it possible to use multiple keys so that they combined will do the action?

Say for instance you want a jump attack that would require two buttons to be pressed at the same time. in this case: space + mouse 1 ?

I tried creating that however it didnt seem to take my input. enter image description here

Does anyone know how this can be achieved?

\$\endgroup\$
1
  • \$\begingroup\$ Unless there has been some update within the last few months allowing you to do this, it is not possible at this stage in unity. You will need to create your own way of checking for this. \$\endgroup\$
    – Savlon
    May 13, 2017 at 22:03

1 Answer 1

2
\$\begingroup\$

You'd have to coordinate the two buttons in your script, something like this:

(adding some leeway in case they're​ pressed a frame or so apart)

public float inputWindow = 2f/30f;
float _attack1Time;
float _attack2Time;

void Update() {
    if(Input.GetButtonDown("AttackButton1")) {
       _attack1Time = Time.unscaledTime;
       if(Time.unscaledTime - _attack2Time < inputWindow)
        DoTwoButtonAttack();
    }
    if(Input.GetButtonDown("AttackButton2")) {
       _attack2Time = Time.unscaledTime;
       if(Time.unscaledTime - _attack1Time < inputWindow)
        DoTwoButtonAttack();
    }
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .