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. Dismiss Notice

Input System, "Hold" action works only once per runtime

Discussion in 'Input System' started by Follet, Jun 5, 2022.

  1. Follet

    Follet

    Joined:
    May 18, 2018
    Posts:
    38
    Hello,
    So I've got my Input System, where for the keyboard, there is a Tap action and a Hold action.
    But the hold action only works once per runtime, so I press play, it detects it the first time, then never again. I've seen old posts saying that from 1.0.1 to 1.0.2 it's been fixed, I am tho in the 1.0.2.

    Code (CSharp):
    1.  
    2. public InputManager IM;
    3.  
    4. void Start(){
    5.   IM.Normal.Hold.performed += TST;
    6. }
    7.  
    8. public void TST(InputAction.CallbackContext context)
    9. {
    10.   Debug.Log("HoldPerformed");
    11. }
    Edit: It is possible that it was the fact of naming my action "Hold", I changed the name and it works well now.
    Edit2: Still, I got a new error "Cannot find action 'Normal/Hold[/Mouse/leftButton]' with ID '1b5fe02a-ddfc-4ceb-9b9f-df051673b815' in 'InputManager (UnityEngine.InputSystem.InputActionAsset)". As seen that also other users have this issue, I can't fix it, I hope it does not give me problems.
    Edit3: Welp, the original issue happens every time I add more than one key to the same action. If it's only one key, it works and detects it every time. If I add more than one binding, it stops working.
     
    Last edited: Jun 6, 2022
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,907
    Follet likes this.
  3. Follet

    Follet

    Joined:
    May 18, 2018
    Posts:
    38