Search Unity

Question Input Actions not working when adding two keys on binding

Discussion in 'Input System' started by slaga, Feb 24, 2021.

  1. slaga

    slaga

    Joined:
    Dec 3, 2018
    Posts:
    142
    as the picture shows with 3 bindings on the same key everything is great but if i add another then it stays looping on hold performed
    Code (CSharp):
    1. public void OnCharge(InputAction.CallbackContext context)
    2.     {
    3.         if (context.interaction is HoldInteraction)
    4.         {
    5.             if (context.performed)
    6.             {
    7.  
    8.                 //Charge();
    9.                 charged = true;
    10.                 Debug.Log("charging");
    11.  
    12.             }
    13.             if (context.started)
    14.             {
    15.  
    16.                 chargedRelease = false;
    17.                 Debug.Log("charging started");
    18.  
    19.             }
    20.             if (context.canceled)
    21.             {
    22.  
    23.                 Debug.Log("charging canceled");
    24.                 chargedRelease = true;
    25.                 colChange.ResetColor();
    26.  
    27.             }
    28.         }
    29.        
    30.     }
     

    Attached Files:

  2. Putcho

    Putcho

    Joined:
    Jun 1, 2013
    Posts:
    246
    write a simple debug and check the log
    Code (CSharp):
    1. public void Shoot(InputAction.CallbackContext context)
    2.         {
    3.             if (context.interaction is TapInteraction)
    4.             {
    5.                 if (context.performed)
    6.                 {
    7.                     Debug.Log("shooting");
    8.                 }
    9.                 if (context.started)
    10.                 {
    11.                     chargedRelease = false;
    12.                     Debug.Log("shooting started");
    13.                 }
    14.                 if (context.canceled)
    15.                 {
    16.                     Debug.Log("shooting canceled");
    17.                 }
    18.             }
    19.         }
    Code (CSharp):
    1. public void Charge(InputAction.CallbackContext context)
    2.         {
    3.             if (context.interaction is HoldInteraction)
    4.             {
    5.                 if (context.performed)
    6.                 {
    7.                     Debug.Log("charging");
    8.                 }
    9.                 if (context.started)
    10.                 {
    11.                     Debug.Log("charging started");
    12.                 }
    13.                 if (context.canceled)
    14.                 {
    15.                     Debug.Log("charging canceled");
    16.                 }
    17.             }
    18.  
    19.         }



     
  3. slaga

    slaga

    Joined:
    Dec 3, 2018
    Posts:
    142
    thank you for the reply but it seems it was a bug. i upgraded to preview 3 1.1.0 and everything works fine now. yeah the canceled never got called before, it stayed in the perfomed loop which i though it was crazy since with one controller only everything worked great but if i added another one then it did that. now i do have the same keys on keyboard and gamepad on different actions and all is ok! thank you!
     
    Putcho likes this.