When 2 keyboard keys are pressed or released simultaneously one of the 2 events is not registered.
- The bug seems to be happening only with the keyboard. Not exactly 100% sure on this but it seem so far.
- 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:
Cache the Vector2 of that action in a Monobehaviour and track it:
using UnityEngine;
using UnityEngine.InputSystem;
public class TestNewIS : MonoBehaviour
{
private static InputSystemMaps inputSystemMaps = default;
[SerializeField] Vector2 input = default;
private void Awake()
{
inputSystemMaps = new InputSystemMaps();
}
void OnEnable()
{
InputAction inputAction = inputSystemMaps.PlayerCharacter.MainAxes;
inputAction.started += UpdateInput;
inputAction.performed += UpdateInput;
inputAction.canceled += UpdateInput;
inputSystemMaps.Enable();
}
private void OnDisable()
{
InputAction inputAction = inputSystemMaps.PlayerCharacter.MainAxes;
inputAction.started -= UpdateInput;
inputAction.performed -= UpdateInput;
inputAction.canceled -= UpdateInput;
}
private void UpdateInput(InputAction.CallbackContext ctx)
{
this.input = ctx.ReadValue<Vector2>();
}
}
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.