Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Input System doesn't trigger anything anymore

Discussion in 'Input System' started by MetalFox, Jul 27, 2019.

  1. MetalFox

    MetalFox

    Joined:
    May 14, 2014
    Posts:
    4
    Hello !

    TL;DR : InputSystem worked some days ago, don't trigger anything anymore, halp.

    I tried the new Input System some days ago, and that's really neat ! I did a lot of stuff, trying to understand the best way to use it, and, in the end, I had a character jumping and moving everywhere, that was cool ! Then, I merged my code in our develop branch and went to bed.

    Today, I want to continue my code, but my character doesn't move anymore, Actions are not triggered (even if inputs are detected in debugger) and I really don't know why. Either the code merge overwrote some important settings (I know what you're thinking and yes, the "Active Input Handling" is set on "Both" and I tried only running the preview) or I did something important during my little tests and I didn't realize.

    So I decided to try to reproduce my steps on a fresh new project, maybe you guys can help me figure what do I do wrong ?

    1/ Create a new 2D project (via the Hub)

    2/ Install the latest Package (version 0.9.0)

    3/ Click Yes on that message prompt to activate the new Input management in the settings
    upload_2019-7-27_13-50-34.png

    4/ Restart Unity Editor since it didn't restart even if the message said it would and check the project settings (yes, it's on "Both", and yes, my Scripting Runtime Version is 4.0)
    upload_2019-7-27_13-52-24.png

    5/ Create a new GameObject and add a PlayerInput on it

    6/ Click on "Open Input Settings" and create an "InputSettings" asset

    7/ Click on "Create Actions..." to create my ActionMap asset

    8/ Create a "TestAction" on my "Player" ActionMap and set it to the key "t"

    upload_2019-7-27_14-0-43.png

    9/ Create a new Script "TestScript" that contains a OnTestAction() method (that only logs "test") and enables the test map/action (just to be sure) :

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.InputSystem;
    4. using UnityEngine.InputSystem.PlayerInput;
    5.  
    6. public class TestScript : MonoBehaviour
    7. {
    8.     void Start()
    9.     {
    10.         InputActionMap playerActionMap = GetComponent<PlayerInput>().actions.GetActionMap("Player");
    11.         playerActionMap.Enable();
    12.         playerActionMap.GetAction("TestAction").Enable(); //Just to be sure
    13.     }
    14.  
    15.     public void OnTestAction()
    16.     {
    17.         Debug.Log("test");
    18.     }
    19. }
    20.  
    10/ Pressing "Play" and spamming "T" like a madman to try to display a debug (note that, in the debugger, a User is created, my "t" presses are detected, my TestAction exists and is mapped on the "t" key but no debug is displayed
    upload_2019-7-27_14-14-50.png

    It's probably a silly problem, but it's driving me crazy, what do I do wrong ? It's even more infuriating that it worked some days ago !

    Additional information :
    - Switching the Input Management from "Both" to "New Input System (preview) does nothing
    - Checking in Update() is my action is enabled returns "True" every frame
    - Checking in Update() is my action is triggered returns "False" every frame
    - Using action.started/triggered/performed does nothing (I tried also switching to UnityEvent or C# events for this) :

    Code (CSharp):
    1. public class TestScript : MonoBehaviour
    2. {
    3.     InputAction a;
    4.  
    5.     void Start()
    6.     {
    7.         InputActionMap playerActionMap = GetComponent<PlayerInput>().actions.GetActionMap("Player");
    8.         playerActionMap.Enable();
    9.         a = playerActionMap.GetAction("TestAction");
    10.         a.Enable(); //Just to be sure
    11.         a.started += OnTriggeredTestAction;
    12.         a.performed += OnTriggeredTestAction;
    13.         a.canceled += OnTriggeredTestAction;
    14.     }
    15.  
    16.     public void OnTestAction()
    17.     {
    18.         Debug.Log("test");
    19.     }
    20.  
    21.     public void OnTriggeredTestAction(InputAction.CallbackContext ctx)
    22.     {
    23.         Debug.Log("test triggered");
    24.     }
    25. }
    - Injecting directly the InputActionReference of my TestAction and using it does nothing
    - Forcing "Default Control Scheme" and "Default Action Map" does nothing
    - Using BroadcastMessage or UnityEvents doesn't work
     

    Attached Files:

    adnanzmn97 likes this.
  2. SnowshoeNyan

    SnowshoeNyan

    Joined:
    Jul 16, 2019
    Posts:
    1
    This happens to me too .-.
     
  3. Stephano

    Stephano

    Joined:
    May 10, 2013
    Posts:
    5
    adnanzmn97 likes this.
  4. MetalFox

    MetalFox

    Joined:
    May 14, 2014
    Posts:
    4
  5. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    75
    I'm having the same problem. And sadly, reboot doesn't helps anything.
    The funny thing is that when i first imported input package, the samples were working perfectly. But when i started to make my controls, generated c# class and implement interfaces, then it stopped working.
    Switching back to old input system, again.. ;(
     
  6. Yecats

    Yecats

    Joined:
    Jul 13, 2014
    Posts:
    23
    @MetalFox (and others) - As a side note, If you do not have a Default Action Map defined in the PlayerInput component, nothing will get routed. It looks like this may have also been a factor, based on your screenshot.

    upload_2019-10-19_15-52-37.png
     
  7. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    75
    My gosh.. This new input system is SOO disgustingly unstable.

    1) It doesn't work when i adding any control scheme
    2) Then Player Input works only with SendMessages or BroadcastMessages behavior
    3) They are dropping fps to zero (with SendMessages), or gives frequent one frame lags with BroadcastMessages. (maybe it's because of debug logs)
    4) Interfaces implementation (from generated C# class) doesn't work as well

    How in the earth i should work with this?
     
    Last edited: Oct 20, 2019
  8. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,463
    Just to make sure I follow. With the current setup you have, if you choose SendMessages or BroadcastMessages, input is indeed coming through as you expect. I.e. all methods are getting called in accordance to input.

    But then, if you switch to UnityEvents and select methods to call for each event, the respective method is *NOT* getting called?

    It is. Many events are high-frequency. Debug.Logs are very expensive (because of the cost of extracting stack traces and in the editor, also due to the cost incurred by the console view which does some expensive searches internally).

    The C# code-generation workflow and PlayerInput are currently not combinable. We'll be looking for ways to use the two together after 1.0.
     
  9. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    75
    Player Input doesn't work at all when i have any "Control Scheme"
    When i don't have it .. It doesn't work as well: upload_2019-10-24_16-35-3.png
    (UnityEvents)
    upload_2019-10-24_16-35-35.png
    (SendMessages / Broadcast)
    Invoke C Sharp Events doesn't call anything at all.


    I've got Input System to work, but without Player Input or C# generated class.
    I'm just directly adding callback methods like this:
    upload_2019-10-24_15-52-20.png

    upload_2019-10-24_15-54-4.png

    I think it should be built-in methods. It's so easy to work with, and it doesn't require C# generated class.

    And, by the way, after i've finally got it to work, New System have impressed me - it's 1000x times better than old system! Cudos! :)
    But i hope it will be more user friendly (especially for not programming people) and Player Input will be fixed
     
  10. drhodor

    drhodor

    Joined:
    Aug 18, 2013
    Posts:
    39
    Everything will also stop working if you delete an old InputActions asset + generated code and try to start with a new one in a project. Even after rebuilding library, which is a bummer.
     
  11. JeffBert

    JeffBert

    Joined:
    Apr 16, 2013
    Posts:
    2
    Any fix for this? The input system is unusable for me because of this. It was working fine before I deleted an old InputActions asset.
     
  12. Grinning-Pickle

    Grinning-Pickle

    Joined:
    Feb 4, 2013
    Posts:
    5
    I thought I'd try this package because it seemed interesting. Unfortunately, issues like this are just mindboggling. You can build a whole fancy system but when inputs get completely ignored, what's the point? Should I ask my players to make sure to reboot their PC before playing my game? No one will and no one should use this package because it doesn't work. Endlessly frustrating and embarrassing.
     
unityunity