Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Issue with value from Trigger input (LT & RT)

Discussion in 'Input System' started by Nylash, Nov 25, 2019.

  1. Nylash

    Nylash

    Joined:
    Dec 4, 2017
    Posts:
    16
    Hello, I try to get the value from left and right trigger on a gamepad but I got an issue. The value is well set (its value depend on how I press the trigger) but when I release the input it's not set to 0. I try the same thing with shoulder input (LB & RB) and it works well, because it is only 1 and 0 I think.

    I must have done an error somewhere in the configuration, there is what I have currently :
    upload_2019-11-25_18-16-15.png
    upload_2019-11-25_18-16-27.png
    upload_2019-11-25_18-16-40.png
     
  2. Amn1C

    Amn1C

    Joined:
    Sep 29, 2019
    Posts:
    10
    I would like to know this too. In the debugger it displays 2 actions for the same button. "Trigger' and "Triggerbutton" where "Trigger" regards sensitivity and "Triggerbutton" goes from 0 to 1 and reverse.

    I don't really know where to make the distinction, but they do interfere and the value doesn't go back to 0 on release.
     
  3. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Darn, I could've sworn I typed up a replay to this. No idea where it went. Alas, here we go.

    So, on one hand, this is expected behavior. On the other, it's certainly not desired behavior and I'll go have a look.

    If you poll the action instead (e.g. playerInput.actions["down"].ReadValue<float>()), you'll probably get the expected result but on this path, you'll indeed end up with an undesirable input value.

    Your configuration should be fine. To explain what's happening, the problem is indeed a peculiarity specific to controls like triggers that can behave like binary buttons (i.e. on/1 or off/2) but are indeed full axes (i.e. full range of [0..1]).

    For these controls, the system uses a configurable "press point" threshold to decide whether the control is considered pressed or not. However, that means that the actual *value* of the control will very likely not be 1 when it is "pressed" and very likely will not be 0 either when it is not "pressed".

    When having access to InputAction.CallbackContext (which, when using the message-based API is not accessible), it's possible to distinguish the two based on the context but regardless, no matter where the input is tapped, I think one should not have to be aware of all this.

    My thinking is that if the *action* type is set to "Button", you should get clean 1 and 0 values regardless of the behavior of the underlying control whereas if the action type is set to "Value", you should get the value from the control as is. But let me have a more thorough look.
     
  4. Amn1C

    Amn1C

    Joined:
    Sep 29, 2019
    Posts:
    10
    Thanks for clarifying this. If I set the action type to button however, the value still doesn't go back to 0 at all. Setting the press point to 1 fixes the problem temporarily but I'm assuming this will get fixed in the future ?
     
  5. Nylash

    Nylash

    Joined:
    Dec 4, 2017
    Posts:
    16
    I eventually suceed to make it works.
    For it I used two differents actions :
    upload_2019-12-5_17-13-11.png
    UpTrigger configuration :
    upload_2019-12-5_17-13-42.png
    UpTriggerRelease configuration :
    upload_2019-12-5_17-14-4.png
    And the piece of code which uses that :
    upload_2019-12-5_17-15-10.png