Any idea how I could solve a double functionality of a controler element? I.e. click to move and shift + click to run on same button? If I define two separated actions, both will always executed and I see no way to block an action if an other has been occured.
I’d suggest using the events. I’m not sure if this is by design, but when I try to use Unity Events, it triggers the method you wire up regardless of the Interaction, making the Interaction useless…but then you can control based on the phase. What you want can be done like this:
private bool triggered = false;
/// <summary>
/// Button you want held down
/// </summary>
/// <param name="context"></param>
public void OnTriggerButton(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
triggered = true;
else if (context.phase == InputActionPhase.Canceled)
triggered = false;
}
/// <summary>
/// The button that will trigger the action if the other is held down
/// </summary>
/// <param name="context"></param>
public void OnActionButton(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed && triggered)
{
// Perform the desired action
}
}
The “cancelled” phase is when you release the button, so you can just flip the bool that way.