Slow tap and Hold incompatible

Reasking an old unanswered question (perhaps a bug).
Apparently, Slow and Hold are incompatible, both can’t be listened at the same time, at least not in the way I would expect. I’m using unity 2019.2.19f1 [Input System 1.0.0],

I’ve already tried to use Button and Value instead of Passthrough, didn’t help.

Depending on their order in the Input Action Asset, Slow Tap OR Hold is called, never both. The way I’m listening to them is like this:

        if (context.interaction is SlowTapInteraction)
        {
            if (context.performed)
            {
                player.ChargeAttack ();
            }
        }

        if (context.interaction is HoldInteraction)
        {
            Debug.Log("is holding");
            if (context.started)
                Debug.Log ("started holding");
            if (context.performed)
            {
                Debug.Log ("Holded");
            }
        }

[EDIT]
If I release the button before the hold time ends, the interaction is executed.
5902931--630104--upload_2020-5-26_23-22-44.png
If I release after the time has passed (it should already have been performed), nothing happens and the ‘is HoldInteraction’ condition is never met.

The way the stack works with this setup and in fact the rather subtle difference between a “hold” and a “slow tap” makes this one confusing. Both of these issues we plan to address.

The key problem here is that the slow tap and the subsequent hold lead to an ambiguous situation…

… with this being the expected outcome.

Confusingly, the way these two interactions work right now, a hold is essentially equivalent to a slow tap except for the minor difference that a hold triggers while the button is still down (i.e. “trigger when the button is held for X amount of time”) whereas a slow tap triggers when the button is released (i.e. “trigger when the button is released after being held for X amount of time”).

With durations for both interactions set to 1 second as in your setup, the hold will never get a chance to actually perform.

  • Button is held for <1s. Will start slow tap on button down (first interaction in stack), then cancel the slow tap on button release (interaction cannot be completed), control passes to hold interaction (that’s what you’re seeing in your code), but then hold immediately cancels, too. It’s probably confusing that the hold is started at all but from the POV of the input system, it is perfectly conceivable that the subsequent interaction is fine completing on the button release. So it will give the interaction a shot at handling the input – which in this case will lead to a second aborted interaction. At this point, control will pass on to Tap – if the button was released within 0.2s, it will perform a tap, otherwise it’ll cancel, too.
  • Button is held for >1. Regardless of when the button is eventually released, Slow Tap will not let control pass on to the hold interaction.

Aside from the interaction stack being confusing in its operation, we hope to improve on how the interactions are defined. And we hope to make the working of interactions more visible in some visual fashion in the editor.

1 Like

thank you very much. currently using two actions as a workaround.