I just wanted to share a different means of setting the IsAttacking property. The InputAction.CallbackContext struct contains the method ReadValueAsButton() which returns true if the button is pressed and false if not. Therefore you could do the following:
public void OnAttack(InputAction.CallbackContext context)
{
IsAttacking = context.ReadValueAsButton();
// Code from the lecture:
// if (context.performed)
// {
// IsAttacking = true;
// }
// else if (context.canceled)
// {
// IsAttacking = false;
// }
}
Whether you choose to use the approach used in the lecture or the code I shared above, It doesn’t really matter, they do the same thing. I just wanted to share in case there are people who are interested.
Cheers