Search Unity

Performed event called seemingly randomly.

Discussion in 'Input System' started by jmparavicini, Jan 25, 2019.

  1. jmparavicini

    jmparavicini

    Joined:
    Nov 28, 2013
    Posts:
    5
    I have been trying out the new Input System and although I have been liking the idea, I have not been able to get it to work properly.

    The problem has been, that after setting up the Action Map and connecting the 'performed' event to a simple Debug statement, the log has been called only sometimes, and it seems like random.

    To explain further, I have set up an Action Map with a simple action, which has a Binding for a key 'space'. I then generated the C# Script and made a simple player script which takes the asset created by the Input System, then connects the performed event of the action to the former said Debug statement.

    I made sure to enable the Input System Reference with 'control.Enable()' on startup. When I start the game, and press the bound key 'space' sometimes, not often, the Debug statement gets executed, and sometimes it doesn't. The result seems to be random, as i have not found out any pattern for when it does log and when it doesn't.

    Some details to my setup:
    1. In player preferences I made sure to set the 'active input handling' to either 'Both' or 'Input System (Preview)'
    2. The package has been included from the package manager
    3. The Scripting Runtime Version has been set to '.NET 4.x Equivalent'
    4. I am using the Unity Beta 2019.1.0a14, and also tried it on Unity 2018.2
    EDIT:

    As mentioned, I have included the generated InputActions C# file and below is the code that interacts with the InputManager.

    Code (CSharp):
    1. public class Character : MonoBehaviour
    2. {
    3.    
    4.     public InputManager controls;
    5.    
    6.     private void Awake()
    7.     {
    8.         controls.Abilities.MainAbility.performed += Test;
    9.     }
    10.  
    11.     private void Test(InputAction.CallbackContext ctx)
    12.     {
    13.         Debug.Log("Ok");
    14.     }
    15.  
    16.     private void OnEnable()
    17.     {
    18.         Debug.Log("Enable");
    19.         controls.Enable();
    20.     }
    21.  
    22.     private void OnDisable()
    23.     {
    24.         Debug.Log("DIsable");
    25.         controls.Disable();
    26.     }
    27. }
     

    Attached Files:

    Last edited: Jan 25, 2019
  2. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    You should probably post your inputactions file and setup code here, I've run into fiddly setup issues earlier on due to the current lack of documentation.
     
  3. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    The problem was the same on 2019.1 and 2018.2(*)? Is this with the 0.1.2-preview package?

    The reason I'm asking is that we had some new code that landed in 0.1.2 but was restricted to 2019.1-only and turned out to cause both loss of events as well as erratic event delays. This sounds pretty close to what you describe.

    We've since moved the code to trunk-only and are working on getting the problem fixed. The next package should run fine on 2019.1.

    However, if you are seeing the problem on both 2019.1 and 2018.3, then it's likely something else.

    (*) We had to drop support for 2018.2. ATM only 2019.1 and 2018.3 are officially supported.
     
  4. jmparavicini

    jmparavicini

    Joined:
    Nov 28, 2013
    Posts:
    5
    To be completely honest, I can not remember the results I got on 2018.X and it can be that it would work there, I am sorry for the misinformation.
    In regards to the 2018.X version I will check on this when I can and update you accordingly.

    Yes this is the 0.1.2-preview package.

    This does sound exactly like my problem. Is there an ETA for the next package that should work on 2019.1?
     
  5. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Awesome. Thanks!

    We wanted to have it out this week (we're already quite late) but turns out my latest batch of changes has introduced a number of problems that need addressing first. Hope is still that we have it out by around mid next week.
     
  6. jmparavicini

    jmparavicini

    Joined:
    Nov 28, 2013
    Posts:
    5
    Ok I have had the time to test the Behaviour on different Unity Versions, and on 2018.2 ,as you mentioned, the package is not available. On 2018.3 the sample script works as expected, so I can confirm this issue with the events being lost, is unique to the 2019.1 alpha.
     
  7. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Ok that's great to hear. Thanks for confirming!

    Next package should fix things on 2019.1. And there's a change in the pipeline that hopefully gets the code causing the problems here to fall in line and do what it's meant to do.