unity runtime_error ai_generated true

InvalidOperationException: Cannot read value for action 'Jump' because the action map 'Gameplay' is not enabled

ID: unity/input-system-action-map-not-enabled

Also available as: JSON · Markdown · 中文
95%Fix Rate
88%Confidence
1Evidence
2023-08-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Unity 2022.3 active
Unity 2023.2 active
Input System 1.5.0 active
Input System 1.6.0 active

Root Cause

The Input Action Map containing the action is not enabled before trying to read its value, typically because Enable() was not called on the map or the InputActionAsset.

generic

中文

包含该动作的输入动作映射在尝试读取其值之前未启用,通常是因为未对映射或InputActionAsset调用Enable()。

Official Documentation

https://docs.unity3d.com/Packages/[email protected]/manual/ActionMaps.html

Workarounds

  1. 95% success In Awake() or Start(), enable the action map before any input read: inputActionAsset.FindActionMap("Gameplay").Enable(); or use inputActionAsset.Enable() to enable all maps.
    In Awake() or Start(), enable the action map before any input read: inputActionAsset.FindActionMap("Gameplay").Enable(); or use inputActionAsset.Enable() to enable all maps.
  2. 90% success If using PlayerInput component, set the Default Map in the inspector to the desired map, and ensure the component is enabled on the GameObject.
    If using PlayerInput component, set the Default Map in the inspector to the desired map, and ensure the component is enabled on the GameObject.
  3. 85% success Use InputAction.Enable() on each action after setting up callbacks, but ensure the parent map is also enabled to avoid conflicts.
    Use InputAction.Enable() on each action after setting up callbacks, but ensure the parent map is also enabled to avoid conflicts.

中文步骤

  1. 在Awake()或Start()中启用动作映射,然后再读取任何输入:inputActionAsset.FindActionMap("Gameplay").Enable(); 或使用inputActionAsset.Enable()启用所有映射。
  2. 如果使用PlayerInput组件,在检查器中设置默认映射为所需映射,并确保组件在游戏对象上已启用。
  3. 在每个动作上设置回调后使用InputAction.Enable(),但确保父映射也已启用以避免冲突。

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Overrides bypass the normal input flow and can cause stale values or conflicts with actual input devices. The action map still remains disabled.

  2. 85% fail

    This defeats the purpose of using action maps for contextual input (e.g., UI vs Gameplay) and may break input switching logic.

  3. 80% fail

    Enabling individual actions without the parent map can lead to inconsistent state and may not register input correctly if the map is disabled.