Search Unity

one single button with "press" and "hold"? Input System

Discussion in 'Input System' started by Rechronicle, Mar 26, 2022.

  1. Rechronicle

    Rechronicle

    Joined:
    Dec 14, 2017
    Posts:
    32
    basically, I want the space key to do different things when the button is pressed & when the button holds.
    How to implement it in the input system?
    The press method is always called first & thus nullifying the hold interaction.

    Thanks!
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Put hold on top of press. The order matters here. The interactions get a shot at processing a given input in the order they appear in.

    So, if press is on top, anything that constitutes a press is consumed and the hold never gets a shot. But if hold is on top, as soon as the hold can no longer progress (button is released before the hold time has elapsed), the next interaction in line will get to have a shot at it.