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

InputSystem HoldInteraction doesn't reset after being performed

Discussion in 'Scripting' started by ProfessorAlbi, Apr 13, 2020.

  1. ProfessorAlbi

    ProfessorAlbi

    Joined:
    Apr 2, 2020
    Posts:
    1
    I'm having trouble with the new input system in unity. I'm trying to set it up so if you hold the button down for x duration you jump higher than if you just tapped the button.

    I have that working but once I hold the button I'm not able to do either action again afterward. I've tried looking at the references for interactions in the manual but I can't see anything that would help me. Am I missing something in the code?

    Code (CSharp):
    1.  public void OnJump(InputAction.CallbackContext context)
    2.     {
    3.         switch (context.phase)
    4.         {
    5.             case InputActionPhase.Performed:
    6.                 if (context.interaction is HoldInteraction)
    7.                 {
    8.                     Debug.Log("High Jump!!!");
    9.                     HighJump();
    10.                 }
    11.                 else
    12.                 {
    13.                         Debug.Log("Regular Jump");
    14.                         Jump();
    15.                 }
    16.                 break;
    17.         }
     
  2. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    I am running into same issue! I am using input system 1.01 and unity 2019.4.16f
     
  3. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    upgraded to 1.1.0 preview 2 fixed the issue