Unity's new input system InputAction sets the threshold of the button

Input Threshold Questions

In the new input system, if you add a handle button, you only need to add Pressed, and you can get press, click, and lift by monitoring his three actions.
insert image description here

For example the following code:

        inputAction.Player.Trigger_Right.started += OnRightTriggerStarted;
        inputAction.Player.Trigger_Right.performed += OnRightTriggerPerformed;
        inputAction.Player.Trigger_Right.canceled += OnRightTriggerCanceled;

But there is a problem here. The Grip button of QuestPro is easy to be accidentally touched. It is triggered by a slight touch. So how to set the trigger threshold? method can be implemented. If there is a better way, please let me know.

Solution

You can try to decompose the Action into 3 parts, and set the PressPoint separately for each one.
As shown in the picture: I use the Grip button here as an example:
I have selected the Axis
insert image description here
Started setting for both types:
insert image description here
the Performed setting:
insert image description here
the Canceled setting:
insert image description here
In the code, there is not much difference, but it is replaced with three different InputActions, and only used performed to trigger:

        inputAction.Player.Grip_Right_Started.performed += OnRightGripStarted;
        inputAction.Player.Grip_Right_Performed.performed += OnRightGripPerformed;
        inputAction.Player.Grip_Right_Canceled.performed += OnRightGripCanceled;

This is done.

Guess you like

Origin blog.csdn.net/thinbug/article/details/131528816