Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
KrishTEEEE's avatar
KrishTEEEE
Honored Guest
5 months ago

Button combo using buttons from both controllers

Beginner developer here, creating my own input actions where I have to press the Left trigger and the Right Primary Button (A) together to do something.

In my Input Actions Editor, under the custom action SwitchMode, I added a binding with one modifier. Left trigger for binding and RightPrimaryButtonPressed for modifier. For testing, my function is as follows:

void OnSwitchMode(){

   print("Mode Switched");

}

I do not get an output on the Console. However when I had both binding and modifier on the same controller (Left trigger, Left primarybutton or the right equivalent), an input is registered and I get a message on the Console.

Why is that? And is there any way to get around this?

3 Replies

Replies have been turned off for this discussion
  • I did not fully understand your question.

    The way I do that kind of thing is use a OnLeftTrigger() and OnRightTirgger() as separate input actions.

    Set a LeftTriggerIsPressed boolean when performed and un-sets it on canceled in OnLeftTrigger.

    Set a RightTriggerIsPressed boolean if performed and un-sets it on canceled in OnRightTrigger.

    Then in both the OnLeftTrigger() and OnRightTirgger() I have 

         ... if (LeftTriggerIsPressed && RightTriggerIsPressed) {

           DoMyThing();

        }

       ...

     

    • KrishTEEEE's avatar
      KrishTEEEE
      Honored Guest

      Right that makes sense, but why can't I use modifiers provided by the Input Actions Editor?

      Usually for button combinations I would just use modifiers, e.g. below OnCombo is called when both shift and space are pressed

      This doesn't seem to be working when i have a binding from my right meta quest 2 controller and a modifier from the left one. They're both under XR Controller in the binding path so I thought there wouldn't be a problem.

      I'd like to know why and is there any other way to get around it other than your mentioned method.

      • RiverExplorer's avatar
        RiverExplorer
        Start Partner

        I had wanted when the 4 (A, B, X, Y) buttons were pressed in different combinations to do things. I could never get it to work. I had assumed it could not (Implementation did not support it), or poor documentation from Unity.