My problem is as follows: I currently have an action map setup with a **"Run"-action, "Button"-type**. This "Run"-action has a **"Hold"-interaction** so that it only registers as performed after a short amount of time.
I want to update a value depending on the phase of the action. If the action was performed (button held for the minimum amount of time) => value = true If the action was canceled (button released) value = false
This approach works really well when I'm *only* using a keyboard - no additional input devices connected. But as soon as I connect my Xbox-Controller, things stop working. There is no "canceled"-phase and the action gets stuck in an eternal "performed"-phase. I checked the input value via ReadValue - that value still changes, but the phase doesn't.
My question: Is there a better way to register a ButtonUp-event on a gamepad or do I need to think of a weird workaround?
My current code (for reference):
public bool RunningInput { get; private set; } private void OnEnable() { playerControls.PlayerMovement.Run.performed += UpdateRunningInput; playerControls.PlayerMovement.Run.canceled += UpdateRunningInput: } private void UpdateRunningInput(InputAction.CallbackContext i) { // If Run was performed => true // If Run was canceled => false RunningInput = i.ReadValue() == 1;
}
I want to update a value depending on the phase of the action. If the action was performed (button held for the minimum amount of time) => value = true If the action was canceled (button released) value = false
This approach works really well when I'm *only* using a keyboard - no additional input devices connected. But as soon as I connect my Xbox-Controller, things stop working. There is no "canceled"-phase and the action gets stuck in an eternal "performed"-phase. I checked the input value via ReadValue - that value still changes, but the phase doesn't.
My question: Is there a better way to register a ButtonUp-event on a gamepad or do I need to think of a weird workaround?
My current code (for reference):
public bool RunningInput { get; private set; } private void OnEnable() { playerControls.PlayerMovement.Run.performed += UpdateRunningInput; playerControls.PlayerMovement.Run.canceled += UpdateRunningInput: } private void UpdateRunningInput(InputAction.CallbackContext i) { // If Run was performed => true // If Run was canceled => false RunningInput = i.ReadValue