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.

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:
    10
    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:

    tonytopper and adnanzmn97 like this.
  2. SnowshoeNyan

    SnowshoeNyan

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

    Stephano

    Joined:
    May 10, 2013
    Posts:
    5
    martyparty1535 and adnanzmn97 like this.
  4. MetalFox

    MetalFox

    Joined:
    May 14, 2014
    Posts:
    10
  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:
    69
    @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,779
    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.
     
    tonytopper likes this.
  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
     
    Daedolon likes this.
  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:
    7
    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.
     
    Waz and JuanFPG like this.
  13. Stefferp

    Stefferp

    Joined:
    Nov 18, 2018
    Posts:
    4
    Hi, could you share that full class? I'm having the same problem too and your solution seems nice and simple. Thanks!
     
  14. midsummer

    midsummer

    Joined:
    Jan 12, 2017
    Posts:
    31
    I updated a project I hadn't touched for a while to the latest 2020.2.0b8 beta. Everything worked, with the exception of all keyboard / mouse input. After spending some time fiddling with the PlayerInput component and inspecting my scripts, I noticed that the value of the Active Input Handling setting had reverted back to Input Manager (old) in Project Settings.

    In this case you'd think that the most simple solution to input not registering would be setting this value back to Input System Package (new) or Both... It would, however, seem that the value can't currently be changed due to some bug or another. Trying to do that just leaves the setting unmodified and writes this error to the console:


    Cancelling Display Dialog : This should not be called when a View's DrawRect Method is in progress


    All other project settings seem to be correct. Only this one detail has been affected by something, likely the process of updating the project for a newer Unity editor version?

    Input System package version is 1.0. I think it was the same before I updated the project.


    EDIT: Apparently the bug with the value of Active Input Handling resetting is a known issue in 2020.2 beta, and will be fixed. Just in case somebody ran into the same problem.
     
    Last edited: Oct 28, 2020
    _slash_ likes this.
  15. _slash_

    _slash_

    Joined:
    Mar 26, 2013
    Posts:
    37

    I have the exact same issue, I even tried thought code using "enableNativePlatformBackendsForNewInputSystem" but the key is not found...

    This works:

    Code (CSharp):
    1. var property = GetPropertyOrNull("activeInputHandler");
    2. var value = 2; //(0: old, 1: new, 2:both)
    3. if (property != null)
    4. {
    5.     property.intValue = value;
    6.     property.serializedObject.ApplyModifiedProperties();
    7. }
     
  16. midsummer

    midsummer

    Joined:
    Jan 12, 2017
    Posts:
    31
    Thanks for the tip, looks like a working workaround. However it would seem that the issue has been fixed in the latest beta version 2020.2.0b14 that I just updated my project to. InputSystem package version is 1.1.0-preview2.
     
  17. EmretheGanjaRaiders

    EmretheGanjaRaiders

    Joined:
    Dec 27, 2014
    Posts:
    21
    my character was able to enter a car and drive it since i build the game it doesnt work anymore. i can run and do everything in the first action map but in the second action map nothing work. in the editor it doesnt work too
     
  18. SaltwaterAssembly

    SaltwaterAssembly

    Joined:
    Mar 8, 2016
    Posts:
    95
    Such an obtuse system
     
    chloelcdev, Waz, RoyBarina and 4 others like this.
  19. UnityMaru

    UnityMaru

    Community Engagement Manager Unity Technologies

    Joined:
    Mar 16, 2016
    Posts:
    1,227
    Please avoid making multiple posts with little to not context. We definitely value feedback, but please try to do this constructively with the one post.
     
    JuanFPG likes this.
  20. giovannazanella

    giovannazanella

    Joined:
    Oct 29, 2018
    Posts:
    3
    I switched my input system to the new one yesterday and everything was working fine, however today immediately after loading the project, my player wasn't even moving.

    After some investigating I realized the problem was that I was calling an action .performed on Awake on one script, while referencing the Input Asset on another script's Awake method. After moving the call to Start ( ) it seems to be working again.

    I am not sure how this was working yesterday though, would appreciate if someone could shine a light on this.
     
  21. Arc-fy

    Arc-fy

    Joined:
    Feb 9, 2020
    Posts:
    7
    Has this been fixed in 1.3? Looks like it might have gotten lost during the bug reporting migration.

    I get the issue where my devices randomly stop working and remain that way even after game restart, but the keyboard still always worked, so I'm wondering if that was related to this.
     
  22. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    145
    Having a similar issue in 2022.2.x with 1.4.4.

    I am using the "Generate C# Class" option. Does the Player Input module still not work with that? That seems unacceptable at this stage without at least a warning message in the Inspector on the component.
     
  23. Waz

    Waz

    Joined:
    May 1, 2010
    Posts:
    279
    I found a comment from a couple of years ago saying they would fix it before 1.0. But who knows. It seems to be working for me so far, but I've only just started a new project and can't even get this "new" system to work at runtime at all.