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.
  2. Dismiss Notice

Bug Action problem when disabled and enabled

Discussion in 'Input System' started by daven8989, Oct 7, 2020.

  1. daven8989

    daven8989

    Joined:
    Jan 25, 2014
    Posts:
    29
    [Unity Version 2019.3.1f1, Input System package 1.0.0]

    Hi, I'm facing a problem with the Action of the new Input System.
    In particular it seems that disabling an Action during the pressing of the associated button makes the action be bugged when the action will be enabled again.

    I'll try to list the behaviour. The context is that I have a Move Action that is a Button with Vector2 value triggered by A and D key. If I press A the value of the action goes to -1,0, if I press D the value of the action goes to 1,0.

    So, following these steps, make the action bugged.
    1. Press A key (or D, it's the same). The value of the action goes to -1,0. (The player start moving to left).
    2. While pressing A key, disable the action. Here there is the first problem (but I think it's how Unity designed the event system related to the Action). The value goes to 0,0 (so it is resetted) but neither the Action.performed (with the resetted value passed in the context) and Action.cancelled event has been throw. So If you are designed the system working only with the action events to detect the change of an action value, you will not be able to detect that the value of the action now is 0,0. But this is not a problem, we can find a workaround to handle the 0,0.
    3. While the Action is disable, release the A key.
    4. After releasing the A key, enable the action again. At this point something seems to be broken. I expect that the action has been "resetted" and so if I press the A key the value of the action will go to -1,0, but the system doesn't work. Basically is like if the Action is "remembering" that the A key was pressed before the Disable () and is waiting for a A key to be released to "reset" the action. So the first time when I press the A key nothing happen, when I release the A key the Action.cancelled is casted and only after pressing again the A key the value of the action will go to -1,0 and the action in general will start to work properly.
    I already tried to make the action type Value or Pass Through but the behaviour is the same.

    Davide.