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

Action with 2 interactions, action canceled is not called

Discussion in 'Input System' started by abel1986, Feb 15, 2020.

  1. abel1986

    abel1986

    Joined:
    Feb 15, 2020
    Posts:
    2
    Hi everyone.

    First of all, Im trying to start with new input system and it really looks great for me, so thanks for Your hard work!

    I stuck with assigment of two interactions to one button, at the moment all .performed action works, but .canceled action seems to work only for PressInteraction, for HoldInteraction its never called. I mean for just click I got .canceled called but if hold button longer i wont get any .canceled called after relase.
    I can add just relase button action to find when hold is canceled but it seems like not proper solution.

    Iv readed thread :
    https://forum.unity.com/threads/hol...oth-actions-when-holding.729887/#post-4872005
    And Rene-Damm posted code with assigment to canceled in HoldInteraction, so it should work and I have no idea what I missed.

    Thanks for any help


    Input actions set like in attachment (just add Navigation to Player in Unity generated asset).

    Code (CSharp):
    1. private void Awake()
    2.     {
    3.         inputControll = new Test();
    4.  
    5.         inputControll.Enable();
    6.  
    7.         inputControll.Player.Navigation.performed +=
    8.             ctx =>
    9.             {
    10.                 NavigationCanceled(ctx.ReadValue<float>());
    11.  
    12.                 if (ctx.interaction is PressInteraction)
    13.                     SetNavigationPoint(ctx.ReadValue<float>());
    14.  
    15.  
    16.                 if (ctx.interaction is HoldInteraction)
    17.                     FollowPointer(ctx.ReadValue<float>());
    18.             };
    19.      
    20.  
    21.         inputControll.Player.Navigation.canceled +=
    22.             ctx =>
    23.             {
    24.                 if (ctx.interaction is PressInteraction)
    25.                     NavigationCanceled(ctx.ReadValue<float>());
    26.  
    27.  
    28.                 if (ctx.interaction is HoldInteraction)
    29.                     FollowCanceled(ctx.ReadValue<float>());
    30.             };
    31.  
    32.  
    33.     }


    <edit>
    I found solution: https://docs.unity3d.com/Packages/c.../manual/Interactions.html#default-interaction
    Mean it work like it should work and I just need some flag to set if follow started and turn it off when button is relased, or try to write custom interaction.
     

    Attached Files:

    Last edited: Feb 15, 2020
  2. kukurenaiz

    kukurenaiz

    Joined:
    Sep 12, 2017
    Posts:
    57
    do you mean hold the button and release before the performed triggers? if the hold interaction is performed, it shouldn't be canceled anymore
     
    Last edited: Feb 17, 2020