Search Unity

Is the new input system ready for production?

Discussion in 'New Input System' started by FeastSC2, May 7, 2019.

  1. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    749
    Hey guys,

    I'm making a game for both controller and keyboard/mouse and I was wondering how stable the new input system is? Will I be able to use it without major hiccups in 2019.1 or is it too early?

    Is it subject to major changes in the future?
     
    Last edited: May 7, 2019
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    4,645
    Depending what you call production ready. If you expect seamless usage and unhindered development, it's not.
    If you have time (I would say at least a year until ship), then you may better off starting to implement.
    I don't think it will change considerably in the future, but of course, it's a preview package, so you never know. This is why it's important that you don't try to use it close to your deadline.
     
    mandisaw, FeastSC2 and LaneFox like this.
  3. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    6,484
    It is not production ready. Things change regularly.
     
    FeastSC2 likes this.
  4. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,633
    Yes, you can still expect one or two batches of changes come in over the next weeks. But after that we expect all feature work to be done, and to focus on polishing and shipping a 1.0 release this summer. So depending on your time frame, if you are ok with some code-changing disruptions coming in the next weeks, slowing down soon after that, you should _probably_ by fine starting to use it now.
     
    GliderGuy and LaneFox like this.
  5. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    749
    Great, I'll start using it then :)

    I was testing it out and I haven't been able to reproduce the UnityEngine.Input behaviour for the gamepad stick.

    Here's what I'm trying to reproduce:
    Code (CSharp):
    1.  Vector2 MoveAxis = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
    In the new input system:
    the Move Action I created is supposed to do the same. However, whenever I stop moving the stick, the Vector2 I read from the Move action does not always equal to Vector2.zero and thus my character keeps on moving.

    upload_2019-5-8_16-9-3.png

    Here's the script I'm using:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Experimental.Input;
    3.  
    4. [RequireComponent(typeof(Player))]
    5. public class PlayerInput : MonoBehaviour
    6. {
    7.     public float MoveSpeed = 7f;
    8.     private Player Player; // A reference to the Control on the object
    9.     private bool Jump; // the world-relative desired move direction, calculated from the camForward and user input.
    10.  
    11.     void OnEnable()
    12.     {
    13.         Inputer.Control.Player.Move.performed += MoveOnPerformed;
    14.         Inputer.Control.Player.Jump.performed += JumpOnPerformed;
    15.         Inputer.Control.Player.Weapon.performed += WeaponOnPerformed;
    16.     }
    17.  
    18.     void OnDisable()
    19.     {
    20.         Inputer.Control.Player.Move.performed -= MoveOnPerformed;
    21.         Inputer.Control.Player.Jump.performed -= JumpOnPerformed;
    22.         Inputer.Control.Player.Weapon.performed -= WeaponOnPerformed;
    23.     }
    24.  
    25.     private void JumpOnPerformed(InputAction.CallbackContext _callbackContext)
    26.     {
    27.         Player.Control.Jump();
    28.     }
    29.  
    30.     private void WeaponOnPerformed(InputAction.CallbackContext _callbackContext)
    31.     {
    32.         Player.AttackNow();
    33.     }
    34.  
    35.     private Vector2 MoveAxis;
    36.  
    37.     private void MoveOnPerformed(InputAction.CallbackContext _callbackContext)
    38.     {
    39.         var value = _callbackContext.ReadValue<Vector2>();
    40.         if (value.magnitude > .1f)
    41.             MoveAxis = value;
    42.         else MoveAxis = Vector2.zero;
    43.     }
    44.  
    45.     private void Start()
    46.     {
    47.         Player = GetComponent<Player>();
    48.     }
    49.  
    50.     // Fixed update is called in sync with physics
    51.     private void FixedUpdate()
    52.     {
    53. //        MoveAxis = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); // this gives me proper values unlike the MoveOnPerformed
    54.         var dir = new Vector3(MoveAxis.x, 0f, MoveAxis.y);
    55.  
    56.         Player.Move(MoveSpeed * dir);
    57.     }
    58. }
     
  6. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    749
    I've been using it for a few weeks now and the new input system is really amazing, it's super flexible! Great job jonas-echterhoff :)
     
    DrummerB likes this.
  7. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    149
    I know this is not out of preview yet, but as of today, can I safely replace SteamVR plugin? Does this support, Valve (index, vive), Oculus, and WMR Controllers?
     
  8. Heimlink

    Heimlink

    Joined:
    Feb 17, 2015
    Posts:
    18
    Is it possible your hardware stick doesn't sit at 0, 0 when it's not being used? You could define a threshold, to only move the characters once the Vector magnitude is greater than a certain value.
     
    Last edited: Sep 9, 2019
    mandisaw likes this.
  9. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,633
    The Input System does support these, but the support is actually being moved out of the Input System package as I'm writing this. Input System 1.0 will be without XR support out of the box. The reason is that the XR team wants to have more control over releasing changes to this, and is moving XR support into separate packages (using the new Input System). These should probably show up a few weeks from now.
     
  10. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    149
    Guess I will be waiting for bit longer. Appreciate the update!
     
  11. terids

    terids

    Joined:
    Sep 23, 2017
    Posts:
    16
    I have this same issue. It is not a deadzone issue, it's that the event doesn't get fired when the stick returns to 0,0 so the last positive value in the previous frame remains. Very annoying bug.
     
    Heimlink likes this.
  12. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,633
    Are you looking at both `performed` and `canceled` callbacks?
     
  13. PixelLifetime

    PixelLifetime

    Joined:
    Mar 30, 2017
    Posts:
    55
    @jonas-echterhoff Hi, sorry to bother you on this thread. I will create a new one if it's better to do so. I was wondering if there is any documentation or tutorials, or if it has supported API to have haptic feedback in new input system. I have found this - https://docs.unity3d.com/Packages/c...gine_Experimental_Input_Gamepad_ResumeHaptics , but it's hard to tell how to use it in correct way without smell code and if it works at all the way I see it could work. I intend to resume and pause haptic in coroutine, is this the right way? Is there any example where I can look it up?
     
    Last edited: Sep 24, 2019
  14. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,633
    Yes, a new thread would be appreciated for new topics.
    Your link is old - we added a lot of documentation since then, the current version docs is at https://docs.unity3d.com/Packages/c...#UnityEngine_InputSystem_Gamepad_PauseHaptics
     
  15. datagreed

    datagreed

    Joined:
    Sep 17, 2018
    Posts:
    16

    @jonas-echterhoff I have the same problem when using Player Input script.

    I have Move control group that binds to left gamepad stick. As far as I can understand from auto-generated file, all events (started, performed, cancelled) call the same function:

    Code (CSharp):
    1. public void SetCallbacks(IGameplayActions instance)
    2.         {
    3.             if (m_Wrapper.m_GameplayActionsCallbackInterface != null)
    4.             {
    5.                 Move.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
    6.                 Move.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
    7.                 Move.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;            
    8.             }
    9.             m_Wrapper.m_GameplayActionsCallbackInterface = instance;
    10.             if (instance != null)
    11.             {
    12.                 Move.started += instance.OnMove;
    13.                 Move.performed += instance.OnMove;
    14.                 Move.canceled += instance.OnMove;            
    15.             }
    16.         }
    So in the actual player controller script I read the axis value like this:

    Code (CSharp):
    1. //....
    2. private Vector2 _moveInput;
    3.  
    4. //...
    5.  
    6. void OnMove(InputValue value)
    7. {
    8.        // i guess this should be called on started, performed and cancelled
    9.         _moveInput = value.Get<Vector2>();
    10. }
    11.  
    12. void FixedUpdate()
    13. {
    14.     print(_moveInput);
    15. }
    Sometimes it does reset to 0,0, sometimes it does not (very easy to reproduce with quick stick flick) and stays at something like (0.4, -0.3). The legacy input system worked fine with the same approach, so I can't blame the gamepad for sure.

    How so I fix this?

    By the way, the Behaviour setting of player input script is set to "send messages" if that's somehow important.​
     
  16. datagreed

    datagreed

    Joined:
    Sep 17, 2018
    Posts:
    16
    GetComponent<PlayerInput>().actions["move"].ReadValue<Vector2>()
    returns correct value at the same time.

    So what should I do to use OnMove() correctly?
     
  17. PixelLifetime

    PixelLifetime

    Joined:
    Mar 30, 2017
    Posts:
    55
    Does this happen when you try to move your stick in a circular pattern? It might have to do with removed `continuous`.
     
  18. datagreed

    datagreed

    Joined:
    Sep 17, 2018
    Posts:
    16
    @PixelLifetime i don’t think the movement pattern before letting off the stick matters. What seems to matter is letting go off the stick from any position as fast as possible, so the spring shoots it back to the center. This is what triggers that problem, that’s why I thought that “cancelled” does not trigger.
     
  19. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,633
    What is your action type? It should be "Value".
     
  20. datagreed

    datagreed

    Joined:
    Sep 17, 2018
    Posts:
    16
    @jonas-echterhoff seems like it was the case.

    Action was set to "Button" (default one). Changing to Action "Value" with Controlt Type "Any" fixed the issue for me.

    Tnank you so much.
     
  21. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    95
    I think this thread lost its track... but in any case, replying to the original question, I am migrating my game to the new input system, it apparently is working well (didnt test in production yet)... but if you take a look at the Issues on Github it's scary, there are dozens of issues from weeks/months ago without even a single reply. If it was a random project I would think it's abandoned.

    https://github.com/Unity-Technologies/InputSystem/issues
     
  22. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,091
    Our issue handling is migrating to FogBugz and the Unity bug reporter. The issue page on GitHub right now is a mixed bag of stuff, with quite a few things being outdated. Once the migration is complete, we will turn off the GitHub issue feature.
     
  23. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    95
    Oh ok, thanks! This makes me feel a bit safer. I will roll my game tomorrow to production with the new input system, I will reply here with the results.
     
  24. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    95
    @Rene-Damm where is currently the best place to open bugs for the NIS?
     
  25. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,091
    Best way is through the Unity bug reporter.
     
  26. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    95
    Thanks. Created case 1193571, maybe it's something you're already aware, which is really bad thing about using fogbugz instead of github issues (cant search the issues, check status, etc)
     
  27. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,091
    Thanks. I'll have a look.

    For the most part, our FogBugz issues are reflected on https://issuetracker.unity3d.com/.
     
  28. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    95
    Just as a fair warning to fellow devs, don't use the New Input System if you target Android. After I did that I started getting dozens of new daily complains/crashes/non-responsive touch/pen not working. I had to roll back the solution to the previous touch and previous Unity version (2019.1), as the pen on 2019.2 isnt working even on the old input. Lost about a month of work, and lots of players and got lots of new bad reviews.
     
    Mat_os and artemio_morales like this.
  29. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    149
    Any word on when the "official/Production ready" release date might be?
     
  30. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    652
    When Unity 2020.1 is released. Judging from past releases, that may be some time between March and June of 2020.
     
    FlightOfOne likes this.
  31. ProtagonistKun

    ProtagonistKun

    Joined:
    Nov 26, 2015
    Posts:
    292
    Is this going to replace the old input system in the long run? Or is this a choice to be made in the editor on which one to use for your projects?
     
  32. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    149
    I'd assume it would have an option to use both (that's how it is now, with the preview version) at least for a while. But as with all things, probably will depreciate it sometime in far future.
     
  33. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,445
    Judging from Unity's history, I'm guessing it will replace the current system when it supports all the things the current one does and they have a way for users to migrate to the new one, OR, they will just deprecate the old one without warning and leave people that depended on various edge features of the old system with no solution.
     
  34. ProtagonistKun

    ProtagonistKun

    Joined:
    Nov 26, 2015
    Posts:
    292
    I wonder if its worth it to work around the GetKey() implementation not being there, or wait for a version where it is implemented and stay with the old system for now. If thats there I dont mind getting rid of the old one, but without it its kinda rough, feels weird to have to work around something rudimentary like that...
     
  35. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    149
    Last edited: Dec 16, 2019
unityunity