Unreachable operation interaction phases?

As the documentation states, interactions are composed of 4 phases: ‘Waiting’, ‘Started’, ‘Performed’ and ‘Canceled’.

To read my inputs, I created functions that return if the pressed action is in its ‘performed’ phase. Example:

public bool GetJump()
{
   return _playerInputActions.Player.Sprint.phase == InputActionPhase.Performed;
}

However, after I started playing with the interactions provided in the input action window (using their default parameter values), I noticed that most of them did not work at all, so I decided to debug every existing interaction using the following code:

private void Update()
{
    Debug.Log("(Key: 0) DefaultAction Phase:" + _playerInputActions.Debug.DefaultAction.phase);
    Debug.Log("(Key: 1) HoldAction Phase:" + _playerInputActions.Debug.HoldAction.phase);
    Debug.Log("(Key: 2) MultiTapAction Phase:" + _playerInputActions.Debug.MultiTapAction.phase);
    Debug.Log("(Key: 3) PressAction Phase:" + _playerInputActions.Debug.PressAction.phase);
    Debug.Log("(Key: 4) SlowTapAction Phase:" + _playerInputActions.Debug.SlowTapAction.phase);
    Debug.Log("(Key: 5) TapAction Phase:" + _playerInputActions.Debug.TapAction.phase);
}

As I suspected, the ‘performed’ phase was not being called for almost any interaction type. While debugging, I tried reaching every phase for every action (by holding, tapping and pressing each button at random intervals), but I noticed that none of the actions returned all of their phases. The least achieved phase was ‘cancelled’, which was not returned by any action:

8934123--1224948--Input.PNG

Can someone explain me what is going on?

I would suggesting registering callbacks, rather than directly checking the current phase of each action.

I’m guessing that you never see “cancelled” because, as soon as the interaction decides that the user cancelled, it goes back to the waiting state!

1 Like

After using your strategy, the inputs started working as intended!

I find it weird that the ‘cancelled’ phase doesn’t appear to endure a single frame, but yeah, registering callbacks is indeed a much more optimal way of doing things anyways.

Thank you very much!

1 Like