Search Unity

Bug with two keyboard keys pressed or released simultaneously

Discussion in 'Input System' started by Nixaan, Jul 8, 2019.

  1. Nixaan

    Nixaan

    Joined:
    May 30, 2013
    Posts:
    118
    When 2 keyboard keys are pressed or released simultaneously one of the 2 events is not registered.

    1. The bug seems to be happening only with the keyboard. Not exactly 100% sure on this but it seem so far.
    2. It can happen with 2 directions in a WASD composite action or across 2 separate input actions that are tied to 2 separate keys.

    The easiest way I found to reproduce is to make a composite WASD action:

    WASD.png

    Cache the Vector2 of that action in a Monobehaviour and track it:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.InputSystem;
    3.  
    4. public class TestNewIS : MonoBehaviour
    5. {
    6.     private static InputSystemMaps inputSystemMaps = default;
    7.     [SerializeField] Vector2 input = default;
    8.  
    9.     private void Awake()
    10.     {
    11.         inputSystemMaps = new InputSystemMaps();
    12.     }
    13.  
    14.     void OnEnable()
    15.     {
    16.         InputAction inputAction = inputSystemMaps.PlayerCharacter.MainAxes;
    17.         inputAction.started += UpdateInput;
    18.         inputAction.performed += UpdateInput;
    19.         inputAction.canceled += UpdateInput;
    20.         inputSystemMaps.Enable();
    21.     }
    22.  
    23.     private void OnDisable()
    24.     {
    25.         InputAction inputAction = inputSystemMaps.PlayerCharacter.MainAxes;
    26.         inputAction.started -= UpdateInput;
    27.         inputAction.performed -= UpdateInput;
    28.         inputAction.canceled -= UpdateInput;
    29.     }
    30.  
    31.     private void UpdateInput(InputAction.CallbackContext ctx)
    32.     {
    33.         this.input = ctx.ReadValue<Vector2>();
    34.     }
    35. }
    Hold both directions (in this case A and D) and try to release them simultaneously. Do this several times until you manage to pull it off and you will see that after both keys are released the cached input Vector2 will become -1,0 or 1,0. Then if you press any key on the keyboard the input will be updated to its correct 0,0 value.

    Same can be tested on pressing left/A and right/D but I find it harder to time simultaneous press. In that case again the input vector will remain non-updated at 1,0 or -1,0 until some key is pressed or released (and its correct 0,0 value appears).

    The same can be seen with 2 separate actions when you press and hold their keys - say left/A and some other action say Jump/Ctrl. I haven't tried this enough but it seems that one keys is correctly considered held down while the other is only briefly detected.
     
    Last edited: Jul 8, 2019
    mowax74, Alverik, JasonSpine and 2 others like this.
  2. TheTamiel

    TheTamiel

    Joined:
    Sep 20, 2018
    Posts:
    1
    +1 on this issue

    github.com/Unity-Technologies/InputSystem/issues/663

    Link to issue thread on the github repo
     
    Alverik, adnanzmn97 and Stephano like this.
  3. Stephano

    Stephano

    Joined:
    May 10, 2013
    Posts:
    5
  4. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    [TL;DR] I duplicate my post on the github here, if anyone has a workaround of this bug, i'm taking it. As my game (rhythm game) needs rapid multiple inputs on keyboard, this issue is happening a lot for me.
    I need to know when a key are pressed, and when it's released. So if someone can show me a way to configure my input actions to get the exact same result but avoiding this bug for now, I'm all ear.

    Thanks a lot !


    ---------
    Hey, I have the same issue. My configuration is a bit different tho and I can add more details to what happen and how to reproduce.
    I'm making a Rhythm Game, and this issue is happening often when I pressed 2 buttons at the same time and release it very quickly.

    I have set all my button this way, for one button, two actions liked :
    - One action set at "Pass Through" for action type and "Any" for Control Type, interaction is "Press", and the trigger behavior is "Press Only".
    - One action set at "Pass Through" for action type and "Any" for Control Type, interaction is "Press" and the trigger behavior is "Release Only".

    Default Press point, tap time, slow tap time, hold etc... are set to zero. The update mode is set to Manual, and i've set it into the dynamic update look, for testing.

    This way I have two actions for one button, one focused on Press only, and the other one to Release only, in separated events (I want it that way).

    The problem happens when I pressed on the same frame 2 buttons and release the two button at the same time very quickly, likely the frame after. Check the debug log :


    You can see on the log that I press down and left on the same frame, so the pressed action is performed, then immediatly after, the release action is started for both keys. I release the both key at the same after, and then, you can see that only the down button has the "performed" state on the release action

    I managed to make the action re-appearing by unfocusing the editor window, and focusing it again, and voilà :


    The action is performed "a bit late".

    For me this happen often because players often quickly smash buttons on the keyboard and I got this issue every 10 secondes on every song I play.
    If anyone has a workaround, I'm taking it too :)

    Thanks !
     
    Last edited: Aug 20, 2019
  5. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    Update on the bug :

    I tried with different configuration :

    First, I set only on action to "PressAndRelease" instead of two actions "Press Only" and "Release only" => The bug still occurs, one of the two buttons doesn't do both of "started/performed" state of the release action.

    Then, I set my two actions to "Button" instead of "Pass Through" for "Press Only" and "Release Only" => The bug still occurs, exactly same behavior than with "Pass Through", release action is "started" but doesn't "perform" until you lose and get focus of the game window again.

    Thanks !
     
  6. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    Update on the bug :

    I don't know if it's related but it seems, happening the same way, when I press two keyboard touch on the same frame.

    What I do is : To prevents the issue happening, I plug the legacy input system (with GetKeyDown and GetKeyUp) on the same keys, and check if there's an event by the legacy system before a new input system event, I trigger a warning and do the event at "Time.realtimeSinceStartup" time.

    Here's a debug log of a press that failed :


    As you can see, I pressed the down and left arrow of the keyboard on frame timed [127,8916]. However, the legacy system triggers before the new input system, that only detect that the touch is pressed on frame [127, 9383].
    Frame is not a problem as the input event can be processed in the next frame if they didn't make it for this frame, I'm totally ok with that because we now have a timestamp that tells when exactly the key has been pressed.

    But now check at the time I logged for the event : The legacy input system is logged at Time.RealtimeSinceStartup = 131,6768, but the new input system returns a context time of 131.7173, which is 40ms late.

    So if I read the datas, it means that the new input system only catch the Left pressed event at least 40ms after the legacy system. Which is supposed to never happen with the new system.
    Because if I understand correctly, the old legacy system simply says at a given frame "hey, there was an input that frame", so the new input system should display only a value of realtimeSinceStartup inferior or equals of the value logged in an update by a legacy system call.

    Which is not the case here.

    So I wanted to check if it's happening only by pressing 2 keys or if it's does the same for one push.

    I pushed 2 keys at the same time 200 times in a row, very quickly. Here's the result :
    - I got a total of 54 warning (so 25% of press), which means the legacy input system has detected an input that is not in the correct state.
    - ~30% was due to the bug describe on this post (New input system triggering a press event later than the legacy system)
    - ~70% was due to the bug described on the previous post (New input system fails to performed the "release" state)

    I pushed one key 200 times in a row, no warnings.
    I pushed very quickly 4 keys one by one around 200 time each (like if you write something on keyboard), only 7 warnings (and after checking the values, it happens when 2 inputs event are really close/on the same frame, so we fall again in my first test case in my opinion), but still, can happen.

    I tested it on Manual Update, Dynamic update, and Fixed updated.

    The first two was given the same result, fixed update makes it worse : There's many much event that have a timestamp later than what we can catch with the legacy system.

    Conclusion : I don't know if I setup my inputs bad, of if there's an issue, but imho, this is weird (especially the part were the input system react after the legacy system).
    If it's an issue, I hope these informations will help you to catch the monster.
    If it's a keyboard-chair interface problem, I will be very happy if someone tell me what's wrong.

    Thanks a lot and have a great day ! :)
     
    Last edited: Aug 20, 2019
  7. Nixaan

    Nixaan

    Joined:
    May 30, 2013
    Posts:
    118
    The other way to "force" the missing event is to press or release any key on the keyboard.
     
  8. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Hey @BenouKat, any chance I can get my hands on the project you're testing this with? Or the test files here? Would love to give this a try. Would be great if you could either upload it through the Unity bug reporter and DM me the case number or just send a zip to rene AT unity3d.com.

    RE timestamps, I have suspicions that something may be going wrong with our timestamp conversion. The input timestamps we keep internally are sync'd to the engine's internal realTimeSinceStartup, which may differ slightly from Time.realTimeSinceStartup in the player and may differ greatly from it in the editor (where Time.realTimeSinceStartup is reset every time you go into play mode). We convert to Time.realTimeSinceStartup on the fly and could be there's actually something not quite right here.
     
  9. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    Yep, if you push any key after the problem, the event appears, but the timestamp is still wrong.
    For exemple if you have the problem, un focus and focus the window again after let's says 5 seconds, the timestamp will be 5 seconds late.
    So if you push any key, the event triggers but the timestamp is the same as the timestamp of the event of the key pushed to "unlock" the situation.
     
  10. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    Hey Rene, sure, i'm going to send you a short project with my actual configurations, test scene and logs. I'll send you that today ! :)

    Regarding Timestamp, honestly i've hit play/stop a terrible amount of time testing, and, aside from the issue we are talking above, I've never noticed a large problem of offsync with the Time.realTimeSinceStartup value (it works so great thanks to your team), so not sure I can help more on this subject :(.
     
    Rene-Damm likes this.
  11. MetalFox

    MetalFox

    Joined:
    May 14, 2014
    Posts:
    10
    Hello ! Are there any news/workarounds about this issue ? I am experiencing the same problem with the 1.0.0 version of the package : my character keeps running if a release two keys at the same time. This keys don't have to be mapped to the same action (or even don't need to be mapped at all : if a release "right" and the "T" button, which is not mapped, the character keeps running right)
     
    Twin-Stick likes this.
  12. Twin-Stick

    Twin-Stick

    Joined:
    Mar 9, 2016
    Posts:
    111
    I'm also being affected by this - looking forward to a resolution (and also glad it's not just me! ha)
     
  13. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    There was a bug report on a related case (which involved having two different composite bindings on one action), which was fixed in https://github.com/Unity-Technologies/InputSystem/pull/753/. I'm afraid that if some folks are still seeing this in 1.0, then there must be something slightly different about these cases, so it would be good to get a repro project for that. @BenouKat, did you ever get around to submitting that project? Or did anyone else?
     
  14. Stephano

    Stephano

    Joined:
    May 10, 2013
    Posts:
    5
    I've just tested and the issue can still very easily be reproduced with the SimpleDemo project that comes with the package. I've mentioned it before

    here:
    https://issuetracker.unity3d.com/is...118.708210337.1569437067-675863237.1557264904

    and here:
    https://github.com/Unity-Technologies/InputSystem/issues/663

    On the github issue I posted a short video on July 16th show casing an easy way to reproduce the issue https://imgur.com/a/GUBrWRg (video is of 0.9.2 but issue is the same in 1.0)
     
  15. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    That bug has been fixed in 0.9.1. I have just retested it - it no longer reproduces in 1.0 (it does still easily reproduce in 0.9). So if you are still seeing an issue it must be separate from that and require different repro steps. I also cannot reproduce this in the SimpleDemo by pressing and releasing A and D at the same time. Do you have any gamepads connected when this happens (that results in different code paths being taken for deciding which device drives the action).
     
  16. MetalFox

    MetalFox

    Joined:
    May 14, 2014
    Posts:
    10
    It's strange, I still have this issue in 1.0.
    I don't have any gamepads connected when that happens.
    If it can help, this specific bug works with keys that are not even mapped to an action. For exemple, if I hold "D" to go right and "L", which is useless and not mapped to any action, and release them at the same time, my character will go right continuously
     
  17. MattRix

    MattRix

    Joined:
    Aug 23, 2011
    Posts:
    121
    Any update on this? We still have the same issue in 1.0.0 preview.3
     
  18. Stephano

    Stephano

    Joined:
    May 10, 2013
    Posts:
    5
  19. FileThirteen

    FileThirteen

    Joined:
    Oct 23, 2012
    Posts:
    40
    I was experiencing this and a friend of mine was not having the same problem. We compared our work and the only difference seemed to be the version of Unity. I was on 2019.1.2f1 and he was on 2019.2.17f1. After I upgraded my version the problem went away.
     
  20. mattinjersey

    mattinjersey

    Joined:
    Dec 3, 2016
    Posts:
    42
    I had problem with 2-buttons at once on Vector 2. I decided to create a separate action for MoveVertical and MoveHorizontal. Then the two button press worked fine.
     
  21. bhavinvs

    bhavinvs

    Joined:
    Jun 21, 2017
    Posts:
    1
    I am still having same issue with latest version. Is there a fix on this?
     
  22. McPeppergames

    McPeppergames

    Joined:
    Feb 15, 2019
    Posts:
    103
    This is driving me crazy! Same issue here!
    I am digging through all tutorials and always having this issue when trying to move a character using the keyboard WASD keys on a MacBook Pro (Catalina 10.15.5). Especially when trying to change a direction or using two keys at once this is happening very often. Sometimes right at start, when for example pushing "W" the characters starts moving like "W" and "A" were pressed at the same time and never released... meaning the character just continues to move into this direction even when no key is pressed anymore. Even pressing a key sometimes is not stopping the character.

    And this is happening with a very simple test like this in Unity 2020.1.6f1:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.InputSystem;
    5.  
    6. public class PlayerController : MonoBehaviour
    7. {
    8.     public float moveSpeed = 100f;
    9.     private GameControls controls;
    10.     public Rigidbody rb;
    11.  
    12.     private Vector2 movementInput;
    13.     private Vector3 inputDirection;
    14.     private Vector3 moveVector;
    15.  
    16.     private Quaternion currentRotation;
    17.  
    18.     private void Awake()
    19.     {
    20.         rb = GetComponent<Rigidbody>();
    21.         controls = new GameControls();
    22.  
    23.         controls.Player.Movement.canceled += ctx => movementInput = Vector2.zero;
    24.         controls.Player.Movement.performed += ctx => movementInput = ctx.ReadValue<Vector2>();
    25.     }
    26.  
    27.     private void Update()
    28.     {
    29.         float xinput = movementInput.x * moveSpeed * Time.deltaTime;
    30.         float zinput = movementInput.y * moveSpeed * Time.deltaTime;
    31.         Vector3 m = new Vector3(xinput, 0f, zinput);
    32.         rb.velocity = m;
    33.     }
    34.  
    35.     public void OnEnable()
    36.     {
    37.         if (controls == null)
    38.         {
    39.             controls = new GameControls();
    40.         }
    41.         controls.Player.Enable();
    42.     }
    43.  
    44.     public void OnDisable()
    45.     {
    46.         controls.Player.Disable();
    47.     }
    48.  
    49. }
    I am testing this using also some post processing effects which are very performance heavy... so the frame rate can be down to 20-30 frames. Maybe this is happening only on "slow" systems?
     
  23. nongbenzgames

    nongbenzgames

    Joined:
    Oct 8, 2018
    Posts:
    19
    Input events would occur on the same frame more frequently at lower FPS. So it makes sense (depending on the InputSystem update mode). I've had a similar issue on mobile which runs lower frames too. Might have to go into the source and try a fix there since this one is very annoying. I really like the new input package but InputSystem should not have left preview status with this issue.
     
  24. Calimar41

    Calimar41

    Joined:
    Nov 26, 2020
    Posts:
    5
    I'm not sure if it's the same issue, but maybe it's worth considering:

    If I press a key, then press a second, then drop the first, the "cancelled" event from the first is delayed until I release the second key. Maybe this provides additional info for reproducibility?
     
  25. Fjoergyns

    Fjoergyns

    Joined:
    Mar 2, 2018
    Posts:
    4
    Code (CSharp):
    1.         moveInputX = 0;
    2.         moveInputY = 0;
    3.  
    4.         if (Input.GetKey(keyRight))
    5.         {
    6.             moveInputX += 1;
    7.             print("right");
    8.         }
    9.         if (Input.GetKey(keyLeft))
    10.         {
    11.             moveInputX -= 1;
    12.             print("left");
    13.         }
    14.         if (Input.GetKey(keyUp))
    15.         {
    16.             moveInputY += 1;
    17.             print("up");
    18.         }
    19.         if (Input.GetKey(keyDown))
    20.         {
    21.             moveInputY -= 1;
    22.             print("down");
    23.         }
    Have the same problem they keyUp, keyDown,... are W, S, A, D. When i press all four buttons at the same time the output will give me sometimes 3 pressed buttons, sometimes 1, but never all four.

    Best regards
     
  26. realevilhq

    realevilhq

    Joined:
    Dec 20, 2020
    Posts:
    1
    I have similar problem. I set up a simple action map:
    Code (CSharp):
    1.  
    2. mPlayerActionMap.AddAction(PlayerCommandUtils.PlayerActions.Forward.ToString(), binding: "<Keyboard>/W");
    3. mPlayerActionMap.AddAction(PlayerCommandUtils.PlayerActions.Backward.ToString(), binding: "<Keyboard>/S");
    4. mPlayerActionMap.AddAction(PlayerCommandUtils.PlayerActions.Left.ToString(), binding: "<Keyboard>/A");
    5. mPlayerActionMap.AddAction(PlayerCommandUtils.PlayerActions.Right.ToString(), binding: "<Keyboard>/D");
    6. mPlayerActionMap.actionTriggered += MPlayerActionMap_actionTriggered;
    7. mPlayerActionMap.Enable();
    8.  
    Input works most of the time, but sometimes key presses are ignored, sometimes one of them occasionally becomes stuck (it generates started and performed actions but not cancelled)
     
  27. BitsAndSpaces

    BitsAndSpaces

    Joined:
    Dec 27, 2020
    Posts:
    6
    I'm on 2019.4.24f1 with Input System 1.0.2 and my on-screen buttons are still getting stuck. It seems to only happen when I press (not hold) two buttons in quick succession, where the second button is stuck in either Started or Performed phase and the only way to get it "unstuck" is to press the stuck button again, which puts it back in Waiting phase.

    The action types on my buttons are Button. One is bound to D-Pad/Left [Gamepad], another is D-Pad/Right [Gamepad], and the third is Button South [Gamepad]. I'm using an On-Screen Button component for each action.

    In my attempt to work around this problem, I tried to do something different. I implemented OnPointerDown to activate my actions while each actions respective button is pressed, and OnPointerUp to deactivate the action when its respective button is no longer being pressed. Unfortunately, I found that the "second button stuck bug" is still happening when I press (not hold) two buttons in quick succession. Investigating further, I implemented OnPointerClick, OnPointerEnter, and OnPointerExit as well. What I found when the problem occurs (second button getting stuck) is that OnPointerEnter and OnPointerDown were the only two events that got called. OnPointerExit and OnPointerUp never happens for the second button.
     
    Last edited: Apr 13, 2021
    mowax74 and JasonSpine like this.
  28. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    I think I reported your exact issue awhile ago and it has been resolved!

    https://issuetracker.unity3d.com/issues/input-system-not-registering-multiple-inputs
     
  29. BitsAndSpaces

    BitsAndSpaces

    Joined:
    Dec 27, 2020
    Posts:
    6
    Awesome, thanks! I'll check that preview out right ASAP. Although, I looked at the link you provided and it looks like there's an opposite effect now? Instead of getting stuck, a person in that link you posted says, sometimes the button does nothing at all.

    "...Upgrading to 1.1.0-preview.3 did indeed fix it, but I'm now seeing the same issue in reverse. That is, pressing buttons in quick succession/simultaneously now sometimes results in one of the buttons _not firing at all_ instead of getting stuck on..."

    Regardless, I think this works out better (at least in my situation) than the button stuck bug.
     
    Last edited: Apr 17, 2021
    mowax74 and MousePods like this.
  30. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Dang :(

    I haven’t tested for that! Are you able to send in a bug report?
     
  31. PostleService

    PostleService

    Joined:
    Feb 28, 2021
    Posts:
    3
    I am still having a problem with converting two buttons pressed at the same time to a proper Vector2. It's registering one button at a time. And I'm using the new 1.0.2 version already.
     
  32. BitsAndSpaces

    BitsAndSpaces

    Joined:
    Dec 27, 2020
    Posts:
    6
    Hey @MousePods, I'm very sorry for the late response. It's been really busy lately. Anyway, I was actually about to submit a bug report. I started a new project just for it using Unity 2020.3.0.f1 and Input System 1.1.0-preview.3, but I can't seem to reproduce this new issue that was mentioned...
     
    MousePods likes this.
  33. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    No problem, hopefully it’s fixed!
     
  34. speppers

    speppers

    Joined:
    Jun 18, 2018
    Posts:
    8
    This is still broken for me in Unity 2020.3.7 and input system 1.0.2 on Mac Catalina. Same issues as above where a key will randomly get stuck. Only been able to reproduce using the keyboard.

    Issue is not present in Unity 2019.4 input system 1.0.2

    Ok one easy way to reproduce this is to hold down any movement key and while holding the key down click on one of the menu items in Unity and then click back into the game view. The vector value will get stuck.
     
    Last edited: May 10, 2021
  35. galkowskit

    galkowskit

    Joined:
    Sep 30, 2015
    Posts:
    3
    This issue still persists for me. If I manually take `ReadValue<Vector2>` in the Update method - it works fine. Trying to subscribe to `started`, `cancelled` or `performed` events will fail.
     
    mowax74 and JasonSpine like this.
  36. alexbu92

    alexbu92

    Joined:
    Apr 7, 2019
    Posts:
    2
    This still exactly happens as described on Unity 2021.1.16f1 with Input System 1.0.2.... How is this possible?
     
    mowax74 and JasonSpine like this.
  37. Quixotical

    Quixotical

    Joined:
    Nov 7, 2020
    Posts:
    2
    'm in the same boat, I was writing up the movement based on the sample unity 3d assets package and I get this issue repeatedly. Basically the same thing everyone is describing. I have Unity 2020.3.0f1 version and my input system package is 1.0.2

    I was using the old input system originally but then felt like "hey it's 2021, I should use the latest and greatest!" Guess that was a mistake, I've spent a week so far trying to fix this before I finally found this specific thread. Glad to know I'm not suffering alone at least, lol.
     
    mowax74 likes this.
  38. Quixotical

    Quixotical

    Joined:
    Nov 7, 2020
    Posts:
    2
    for fun I just tried to separate the actions so that W (up) is it's own action, and then left/right/back is it's own action, thinking maybe it got confused when reading multiple keys from the same action group, but I can still recreate the error.
     
  39. Pellens

    Pellens

    Joined:
    Nov 5, 2020
    Posts:
    1
    Still waiting for a fix on this... Any news?
    I'm using Unity 2021.2.7f1, having the same issue.
     
    Last edited: Jan 1, 2022
    Liammonks and kyuskoj like this.
  40. kyuskoj

    kyuskoj

    Joined:
    Aug 28, 2013
    Posts:
    56
  41. dvdfu

    dvdfu

    Joined:
    Sep 1, 2015
    Posts:
    11
    Experiencing issues with Unity 2020.3.15f2, Input System 1.3.0.

    I have just 2 button actions, with no interactions + processors. When pressing both quickly at similar times (through an On-Screen Button), one of the 2 inputs doesn't receive a "Performed" callback. This seems to happen mostly on Android builds.

    Strangely, I have the reverse problem in the editor, where sometimes keyboard inputs for the same button actions will not call the "Canceled" callback, leading to the button read as held down despite none of the buttons physically held!

    These inconsistencies happen quite often and without clear conditions. It's making the new input system unusable for me.
     
    mowax74 likes this.
  42. Zexar98

    Zexar98

    Joined:
    Apr 4, 2019
    Posts:
    5
    I have the same problem (sorry for my bad english, i am spanish).

    Unity 2021.2.12f1
    Input System 1.3.0

    In a 2D game with URP, i have 2 movement buttons (move left / move right). In adittion Jump, Dash, Attack.
    So I have a player controller script (in a Prefab with rigibody2d, sprite renderer, etc):

    private PlayerInputSystem playerInput; //Input System//
    private InputAction inputSlide, inputJump, inputAttack, inputMove;

    private void Awake() => playerInput = new PlayerInputSystem();

    private void OnEnable()
    {
    //Enable controls//
    inputSlide = playerInput.Player.Slide;
    inputSlide.Enable();
    inputSlide.performed += OnSlide;

    inputJump = playerInput.Player.Jump;
    inputJump.Enable();
    inputJump.performed += OnJump;
    inputJump.canceled += OnJump;

    inputAttack = playerInput.Player.Attack;
    inputAttack.Enable();
    inputAttack.performed += OnAttack;

    inputMove = playerInput.Player.Move;
    inputMove.Enable();
    }

    private void OnDisable()
    {
    //Disable controls//
    inputSlide.Disable();

    inputJump.Disable();

    inputAttack.Disable();

    inputMove.Disable();
    }

    private void Update() => horizontalMove = inputMove.ReadValue<float>();

    FixedUpdate { here rigidbody.Movement = horizontalMove and more code... }

    private void OnSlide(InputAction.CallbackContext ctx)
    {
    //logic//
    }

    private void OnAttack(InputAction.CallbackContext ctx)
    {
    //logic//
    }

    private void OnJump(InputAction.CallbackContext ctx)
    {
    //logic//
    }

    ------------------------------------------------------------------------
    In Unity editor work as expected, but when i am going to generate release apk (LZ4HC compression method, net framework 4, il2cpp) and i am going to install to my personal android mobile, is not working as expected (as Unity editor).
    If i Move Right and Move Left, in some cases canceled event is not executing (keeps performed phase).

    If I change/reload scene with the same Prefab Player (enable/disable controls), player prebaf sometimes starts jumping, dashing or attacking (i think it is the same as movement case -> composite binding, simple button, etc have a internal bug in android).
    If i am going to next level, when i am going to move right, and I am going to up my finger, player move lefts (because input system continues executing move left form other scene. Input System keeps phase i think, so move.disable() i s not working as expected i think).

    In editor no problems, only in android debug/release generated apk.

    My input actions:
    Move Value Axis -> 1D Axis with Left/Right arrow (Negative/Positive)
    Jump button Z (initial state check false)
    Attack button X (initial state check false)
    Dash button C (initial state check false)

    No processors/Interactions
    In canvas using On-Screen Button (Input System Script). If I press in Unity editor with mouse works as expected

    Input System is life for me, but in this state is unusable for me too (like dvdfu says)
     
  43. Lughinu

    Lughinu

    Joined:
    Nov 3, 2016
    Posts:
    11
    same problem
    Unity 2021.3.1f1
    Input System 1.3.0
     
    mowax74 likes this.
  44. allangamesxbr

    allangamesxbr

    Joined:
    Sep 9, 2015
    Posts:
    25
    same problem
    Unity 2021.2.11f1
    Input System 1.3.0
     
  45. Mimecrime

    Mimecrime

    Joined:
    Apr 13, 2022
    Posts:
    1
    I am having problems trying to keep the a reference of the input value derived from a 2D Vector using Digital Normalized mode once I release two keys that are being held down at the same time.

    The summarize it briefly, I need a refernce to the direction which was active during the frame that the action was canceled. The reason for this is because i need the angle in order to keep the Camera calibrated and centered.

    I am using a WASD binding where W = North (0), D = East (90), S = South (180) and A = West (270).

    Technically the input I am getting is: W = (0;1), D = (1;0), S = (0,-1) and A = (-1,0)

    When pressing two buttons down, for example W and D, I want them to represent 45 deg, tehcnically it is (0.71; 0.71).

    But the problem I run into is that technically, if you are holding down two buttons (for example W and D) and "release" them both, you technically release them at different points of time (in the realms of ms).
     
    VeryHotShark likes this.
  46. VeryHotShark

    VeryHotShark

    Joined:
    Mar 11, 2017
    Posts:
    13
    Im having the exact same case :D Did you manage to fix it simehow?
     
  47. DBarlok

    DBarlok

    Joined:
    Apr 24, 2013
    Posts:
    268
    I am seeing the exact same issue!! 2023! it is fixed? Help!
     
  48. ThreedaysX

    ThreedaysX

    Joined:
    Jun 24, 2018
    Posts:
    1
    In Unity 2021.3.36f1, with new Input System version 1.7.0, I'm still encountering the same issues. Whenever I quickly tap ASD or the arrow keys ←↓→ (movement keys), the log displays an unexpected message.

    Here's what I expected:
    1. InputAction_performed:: Move && /Keyboard/leftArrow
    2. InputAction_performed:: Direction && /Keyboard/downArrow
    3. InputAction_canceled:: Move && /Keyboard/leftArrow
    4. InputAction_performed:: Move && /Keyboard/rightArrow
    5. InputAction_canceled:: Direction && /Keyboard/downArrow
    6. InputAction_canceled:: Move && /Keyboard/rightArrow

    The third and fourth points can be swapped, but it's not crucial (as the user may have released the key first).

    Any ideas?

    upload_2024-4-15_1-59-48.png