Search Unity

Using ButtonWithOneModifier without triggering another action using the same binding?

Discussion in 'Input System' started by Mman1235, Nov 9, 2019.

  1. Ravengrim

    Ravengrim

    Joined:
    Apr 13, 2015
    Posts:
    5
    I have the InputSystem 1.5.1 installed and I can't get it to work.
    I configured two Actions like so:
    p1.PNG

    But pressing Ctrl + A triggers both actions. Is there any way to prevent the first Action from occuring when pressing Ctrl + A?
     
  2. niuage

    niuage

    Joined:
    Nov 17, 2019
    Posts:
    123
    This behavior is not on by default, you need to change your settings. Have you done so? If not, I think it's mentioned in the previous comments.
     
  3. Ravengrim

    Ravengrim

    Joined:
    Apr 13, 2015
    Posts:
    5
    Hi niuage, thanks for the hint! I found the setting now and got it to work.

    For anyone else wondering, it's in the Project Settings under Input System Package:
    input.PNG
     
    quangprox121, mackeraldev and niuage like this.
  4. gentlegorilla

    gentlegorilla

    Joined:
    Jun 18, 2019
    Posts:
    19
    Should that also work with other then keyboard shortcuts? Trying to set up actions that differ between how many fingers are on a touchscreen. If I understood the consumption description right, my action with one modifier touch contact 0, should not be triggered, when I touch with two fingers, as there is also an action with two modifiers checking contact on touch0 and touch1, as this one has the most modifiers set.
    At least it does not work this way for me, always my one modifier action is performed.
     
  5. dekubee

    dekubee

    Joined:
    Jun 14, 2020
    Posts:
    2
    So, I'm trying to create an input system based around fighting games and I just wanted to report this odd thing using input consumption. So, basically I have three input actions that are relevant here: Left Punch, Right Punch, and Left Punch + Right Punch.
    Left Punch is mapped to "O", Right Punch is mapped to "P", and Left Punch + Right Punch is a "Button with One Modifier" - it's button is "O" and the modifier is "P". Pressing O+P results in either Left Punch going off as well as Left Punch + Right Punch. I don't think it has anything to do with my code, because when I change the modifier or the button to shift, it works as intended. However, I'm not certain on that.
    I for sure have Input Consumption enabled in my project settings.

    EDIT: Reading the documentation, this appears to be the intended function, in some way. At least, it doesn't appear I'm using it the way it's intended.
     

    Attached Files:

    Last edited: Apr 30, 2023
  6. niuage

    niuage

    Joined:
    Nov 17, 2019
    Posts:
    123
    Couldn't it simply be that you're not pressing both buttons the same frame? If both your buttons have other functions, then it makes sense that the individual actions would be performed, as it's hard to press both buttons during the same frame. If you made shift an action as well, you'd have the same problem I think.

    I think you need game code to make that work properly. Usually fighting games have some input buffer. So basically when your player press O or P, you dont immediately perform the action, you wait a tiny bit of time and if the opposite letter is performed, then you perform the O+P.
     
  7. dekubee

    dekubee

    Joined:
    Jun 14, 2020
    Posts:
    2
    Funnily enough, after making that post I did some more research on this very same forum and found that same answer, more or less. I actually do have an input buffer — well, a circular buffer that stores inputs but that's half of the work. But I was hoping I could relegate the polling of inputs to the input system, which as I see now, won't be as simple as storing the input action into an array. At least if I wanna do simultaneous inputs.
     
  8. pmoraes

    pmoraes

    Joined:
    Apr 6, 2016
    Posts:
    6
    I can't get it to work, using 1.6.1, I selected the config to consume inputs but I still get both input events

    upload_2023-6-15_21-46-49.png

    upload_2023-6-15_21-46-21.png
     
  9. _alphaBeta_

    _alphaBeta_

    Joined:
    Aug 8, 2014
    Posts:
    38
    Is InputSystem 1.5.1 the latest released version? I see documentation for 1.6.1, but package manager only goes up to 1.5.1 for me on Unity 2021.3.26f1. Is my editor too old?

    Regardless on 1.5.1, with the input consumption option enabled, I still cannot get this to work with axis. All I want to do is have my mouse scroll wheel zoom a camera, and when holding CTRL with scroll wheel, change a camera elevation. Holding CTRL and scrolling the mousewheel fires both actions.

    I did get this to work as I intended by using TRS6123's solution in this thread. I'm just going to go with this for now unless it breaks something else down the road.
    input.jpg
    Using his solution, the top modifier has the negate button processor applied and two of the axis bindings have invert processors applied. Whew.

    Much thanks @TRS6123, considering it's beyond my current skill to extend the Input System like this. Hopefully I'll be able to use your examples to find my way through this eventually. Of course, I shouldn't really have to. Coming back to Unity after several years, I'm disappointed to have hit this. I spent hours trying to figure this out and the old system would have been minutes.