InputAction event triggered even if it is disabled

So, I have an Input Action Asset with some InputActions.
I execute the following code:

inputsModel.NextCameraPositionInput = InputSystem.actions.FindAction("NextCameraPosition");
inputsModel.NextCameraPositionInput.performed += (obj) => CameraMovementController.MoveToNextPosition();

The NextCameraPositionInput is correctly setup, but I’m not performing any NextCameraPositionInput.Enable() to enabled the action.
I’m even using the NextCameraPositionInput.Disable() to make sure the InputAction is disabled.

Despite that, when I press the binded Keyboard keys (this action uses the ‘z’ key), it triggers the “performed” event. AFAIK the event should not trigger because the InputAction is not only not being enabled but I’ve also disabled it.

Maybe there is some other way to disable inputs but my idea is to specifically disable just some of them.
e.g. Disable the next camera position input but not the previous one.

¿What am I doing wrong?
¿Will the event trigger even if I don’t enable the InputAction?

The project-wide actions asset’s actions are automatically enabled by default. It seems like this happens after the point where your script’s Awake gets called, getting enabled after your script disables it. You could Instantiate the asset (clones it) to create one with the same content but isn’t enabled by default. You could also change or remove the project-wide actions asset if you don’t want to have those actions globally accessible and active from the start, instead referencing it from a serialized field in your behaviour.

I also have the same issue.
I use project-wide actions, and the actions in the non-active ActionMap are activating as well as the ones in the active action map.
The actions are disabled, and they are still activating. This has to be a bug?
EDIT:
If I disable the non-active actionmap on awake, the build no longer triggers the other actions. Although this does not work in play mode.

I had this issue while using the Player Input component and the default “InputSystem_Actions”.
It seems like it is because the default project-wide input actions are enabled after my Game Manager had run Start() and disabled the action map.

A very easy solution in this case:

  • In Project Settings → Input System Package, set the Project-wide Actions to point to None.
    Then enabling and disabling action maps on startup worked as normal for me in Unity 6.
1 Like

I think this behavior is due to how the Input System initializes. In my own testing, if I disable input maps in an Awake or Start method, they end up being immediately re-enabled.

I’ve found that it works if you wait, not one, but two frames:

async UniTask DisableInputMaps()
{
    await UniTask.DelayFrame(2);
    MyMap.Disable();
}

So yes, I would consider this to be a race condition bug.