As title suggestions the input is incorrect for me if the name matches, for example I have
Example when I'm calling
I solved it by marking the method
There is likely a better way to handle this, but it solves the issue for me.
Gameplay/Mouse X
which I use, then when I switch action map to UI I also have UI/Mouse X
. In UnityInputSystem
it uses the action key without any context to its action map. Meaning I get Gameplay/Mouse X rather than UI/Mouse X (which is always 0 since Gameplay is not active).Example when I'm calling
playerInput.GetAxis("Mouse X")
I solved it by marking the method
protected virtual
and then using the fully qualified name:
C#:
protected override InputAction GetActionByName(string name) {
string prefix = m_PlayerInput.currentActionMap?.name;
string fqn = prefix + "/" + name;
if (!m_ItemActionByName.TryGetValue(fqn, out var itemAction)) {
itemAction = m_PlayerInput.currentActionMap?.FindAction(name);
m_ItemActionByName.Add(fqn, itemAction);
}
return itemAction;
}
There is likely a better way to handle this, but it solves the issue for me.
Last edited: